Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Asset path with Multilingual set

Started by Richard Hainsworth 8 years ago · 0 replies · 477 views
8 years ago

Adding this note in case someone else hits a similar problem.

I implemented a plugin which needs to load a JS file. Initially, I added the js file in onPluginsInitialized with the line (datatables being the plugin)

PHP
$this->grav['assets']->addJs( 'plugin://datatables/assets/datatables.min.js');

This worked fine until I changed the site to multilingual, and then the js file was no longer loaded.

The problem was that the Grav System was loading from

TXT
<pathtoplugin>/en-gb/datables/assets/datatables.min.js

Note the en-gb, which is added for multilingual sites.

My solution, which I think is a correct one, and something that may be should be documented in the Multilingual section, is

  • Register a callback to onAssetsInitialized
  • create a function onAssetsInitialized
  • add the assets in that function.
last edited 04/06/18 by Richard Hainsworth

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 47 1 week ago
Plugins · by Xavier, 4 weeks ago
2 56 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1182 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 50 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 74 2 months ago