Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Add JS to admin - How to

admin

Started by Kenneth Joris 8 years ago · 1 replies · 1148 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 Marcel, 5 days ago
0 85 5 days ago
Support · by JakobDB, 6 days ago
1 91 6 days ago
Support · by ramenos, 7 days ago
3 103 6 days ago
Support · by gravinator, 2 weeks ago
3 229 7 days ago
Support · by Roger Parkinson, 2 weeks ago
3 308 2 weeks ago