Adding blueprints to plugin pages

  1. Create a blueprint for your page, say gallery.yaml and put in the fields you want, or extend the default page (read the docs on that here).
  2. Put that blueprint in a blueprints/ folder in your plugin folder.
  3. Register those blueprints in your plugin.php code by adding the following bits:
    use RocketTheme\Toolbox\Event\Event;

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

    /**
     * Add blueprint directory to page templates.
     */
    public function onGetPageTemplates(Event $event)
    {
        $types = $event->types;
        $locator = Grav::instance()['locator'];
        $types->scanBlueprints($locator->findResource('plugin://' . $this->name . '/blueprints'));
        $types->scanTemplates($locator->findResource('plugin://' . $this->name . '/templates'));
        // ^^^ only necessary if you also have templates in your plugin
    }


  1. Give your page that template, save and voilà! your fields should turn up in the Admin interface. :slight_smile:

Hope this helps! (Actually I think most of this is in the docs I referenced above, but it might still help you and others out by condensing those a bit. :wink: )