2

You are using onAfterRender event which is not suitable for modifying the document object because this event is triggered after the page has already been rendered. Use onAfterDispatch, onBeforeRender or onBeforeCompileHead instead.


2

$document->addScriptDeclaration() method is working, no problem with that. window.event is deprecated: https://developer.mozilla.org/en-US/docs/Web/API/Window/event instead of that you should use document.addEventListener() or window.addEventListener() on the event of DOMContentLoaded https://developer.mozilla.org/en-US/docs/Web/API/Window/...


2

Plugins can be fickle things to get right, so here's a short guide to getting your plugin working successfully. Identify the Plugin Type and Event Firstly work out which event you need to subscribe to. The events which are emitted by Joomla are listed in https://docs.joomla.org/Plugin/Events, and these are segregated by plugin type. Unfortunately it's not ...


2

If I were you I would try this instead of onBeforeRender: onBeforeCompileHead That way you are adding the meta to the document prior to it being rendered. Here is an excellent video explaining all the different plugin types, but admittedly it can take a while to get your head around them. https://www.youtube.com/watch?v=_agXP5DHm_g&list=...


Only top voted, non community-wiki answers of a minimum length are eligible