Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Stuck with plugin port to Grav v2 - admin page tab missing

admin form plugin plugins

Solved by Karmalakas View solution

Started by Karmalakas 1 week ago · 2 replies · 184 views
1 week ago

I already asked on discord, but didn't get any advice, so maybe someone here can help

I can't figure out why a custom tab with the form doesn't appear on the page edit. Based on the manual, nothing should've really changed. What's missing in my plugin?

1 week ago

Hi @Karmalakas, should your plugin add a page template or a tab to all pages?
Ok, it looks like this is supposed to be a page, and you’ve already received a working answer. Just tested :)

last edited 11/22/26 by Vadym
1 week ago Solution

I see and it works as expected now. I'll just copy @rhuk's response here as a solution:

Nothing's wrong with your blueprint. The catch is the isAdmin() check around onGetPageBlueprints / onGetPageTemplates. Admin2 edits pages through the API plugin, and during an API request isAdmin() is still false when onPluginsInitialized runs, so your plugin never registers its blueprint or template. Subscribe to those two events unconditionally. They only fire when Grav builds its list of page types, so they cost nothing on the frontend:

PHP
public function onPluginsInitialized(): void
{
    $this->enable([
        'onGetPageTemplates'  => ['onGetPageTemplates', 0],
        'onGetPageBlueprints' => ['onGetPageBlueprints', 0],
    ]);

    if ($this->isAdmin()) {
        return;
    }

    $this->enable([
        'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
        'onTwigExtensions'    => ['onTwigExtensions', 0],
    ]);
}

Then run bin/grav clear, because page types are cached. Also, since your blueprint is its own page type extending default, the tab only appears on pages using the "Image comparer" template, not on every page. That works the same as in classic admin. Our docs still show the isAdmin() version, which is my fault. I'll fix that, and I'll also make the API handle the old pattern so existing plugins work unchanged.

👍 1
last edited 11/22/26 by Karmalakas

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 22 hours ago
2 39 15 hours ago
General · by Hanns Mattes, 1 week ago
0 119 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 234 3 weeks ago
General · by Dima, 4 weeks ago
1 210 4 weeks ago
General · by pamtbaau, 1 month ago
0 335 1 month ago