2

Is there a way to add Javascript to the Joomla Administrator template without creating a child template?

Something equivalent to /media/templates/administrator/atum/css/user.css for Javascript.

2 Answers 2

1

You could create a system plugin that only works in the back-end and loads some JavaScript file.

Probably with something like:

defined('_JEXEC') or die;

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\CMSPlugin;

class PlgSystemPluginname extends CMSPlugin
{

  protected $app;

  public function onAfterRender()
  {
    // Quit this when the app is not in the administrator back-end
    if (!$this->app->isClient('administrator'))
    {
      return;
    }

    // Load some JavaScript file
    HTMLHelper::_('script','com_foo/foo.js', 
    ['version' => 'auto', 'relative' => true]);
  }
}
1

bug open at https://issues.joomla.org/tracker/joomla-cms/43320

Meanwhile, you may add your javascript in the /media/templates/administrator/atum/js/template.min.js

I will update here if it is solved

New contributor
random42092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.