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 · 1017 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 BenLaKnet, 6 days ago
1 125 3 days ago
Support · by BenLaKnet, 1 week ago
5 196 3 days ago
Support · by kskt, 3 days ago
0 48 3 days ago
Support · by David Meissner, 3 days ago
0 48 3 days ago
Support · by David Meissner, 4 days ago
3 94 3 days ago