Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Add JS to admin - How to

admin

Started by Kenneth Joris 8 years ago · 1 replies · 1098 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 Paul Hodges, 4 weeks ago
19 483 5 days ago
Support · by Lauw, 7 days ago
2 99 6 days ago
Support · by Anna, 3 weeks ago
4 426 1 week ago
Support · by gtx, 4 weeks ago
4 377 3 weeks ago
Support · by Anna, 1 month ago
9 484 3 weeks ago