I've been trying for the last hour or so to get a single javascript added to the head via my system plugin, and am kind of pulling my hair out as to why it is not showing up.
Here's what I've got going in my plugin php file so far:
<?php
//no direct access
defined('_JEXEC') or die;
class PlgJoomlaKey extends JPlugin
{
public function onAfterRender ()
{
//only going to run these in the backend for now
if ($app->isSite()) {
return;
}
$document = JFactory::getDocument();
$document->addScript(JUri::root().'plugins/system/joomlakey/joomlakey.js' );
}
}
I'm obviously doing something wrong, but I have no clue what. I've tried as many different functions besides onAfterRender as I can see might work, but none of those seem to change anything. I've tweaked the file path every which way but that doesn't seem to be the problem (besides, it should add it, I'd at least see the (wrong) file path in the head).
I know the plugin is loading, because I can type, say, break
right above the comment of //only going to run ...
which then breaks my site when I reload - so the plugin is executing, but for some reason that script is not getting placed in the head like it should be.