Skip to content
● Critical PHP security fixes are out: update PHP on your Grav sites. What to do →

Add JS to admin - How to

admin

Started by Kenneth Joris 8 years ago · 1 replies · 1246 views
8 years ago

I don't know if its the correct hook. But this code seems to work.

This code goes into your themeName.php file,
located at user/themes/themeName/themeName.php

PHP
<?php
namespace Grav\Theme;

use Grav\Common\Theme;

class Base extends Theme
{
    // Add assets to the Admin
    public function onAssetsInitialized() {
        if ($this->isAdmin()) {

            // add JS
            $this->grav['assets']->addJs('theme://js/admin.js');

        }
    }
}
👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by webmasterodp, 2 weeks ago
4 250 2 weeks ago
Support · by nwhitfield, 2 weeks ago
2 214 2 weeks ago
Support · by stell, 4 weeks ago
5 458 3 weeks ago
Support · by gravinator, 2 months ago
5 638 3 weeks ago
Support · by Gravver, 1 month ago
6 430 4 weeks ago