Overwrite AdminPlugin pages.html.twig

Is it possible to overwrite the AdminPlugin pages.html.twig file with another plugin? I need a customized view of the pages without touching the AdminPlugin itself.

You can create a plugin that hooks in the onAdminTwigTemplatePaths event and provides a Twig templates folder, like

public static function getSubscribedEvents()
{
    return [
        'onPluginsInitialized' => ['onPluginsInitialized', 0],
        'onAdminTwigTemplatePaths' => ['onAdminTwigTemplatePaths', 0]
    ];
}

public function onAdminTwigTemplatePaths($event)
{
    $event['paths'] = [__DIR__ . '/admin/templates'];
}

It works… thx alot

Fix as per issue reported in https://github.com/getgrav/grav-plugin-admin/issues/999:

The above suggestion works only if a single plugin is overriding / providing an Admin twig template, which is not correct to assume.

As otherwise the last plugin that executes (lower priority), will have the final word.

Instead, use:

public function onAdminTwigTemplatePaths($event)
{
    $event['paths'] = array_merge($event['paths'], [__DIR__ . '/admin/templates']);
    return $event;
}

(adding to the paths, not overwriting the paths array on every plugin event execution) will do the correct job.