Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Asset path with Multilingual set

Started by Richard Hainsworth 8 years ago · 0 replies · 630 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 complanar, 2 weeks ago
2 250 4 days ago
Plugins · by Vladimir Novak, 1 month ago
3 594 1 month ago
Plugins · by Mathieu Lecouturier, 2 months ago
3 416 2 months ago
Plugins · by Slebeig, 2 months ago
1 530 2 months ago
Plugins · by Rene, 3 months ago
2 730 3 months ago