['onPluginsInitialized', 0], ]; } /** * Enable search only if url matches to the configuration. */ public function onPluginsInitialized() { if (!$this->isAdmin()) { return; } $this->enable([ 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], 'onAdminTemplateNavPluginHook' => ['onAdminTemplateNavPluginHook', 0], 'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0], ]); $comments[] = [ 'route' => 'comment-test-1', 'content' => 'A comment text' ]; $this->grav['twig']->comments = $comments; } /** * Add plugin templates path */ public function onTwigTemplatePaths() { $this->grav['twig']->twig_paths[] = __DIR__ . '/admin/templates'; } /** * Add navigation item to the admin plugin */ public function onAdminTemplateNavPluginHook() { $this->grav['twig']->plugins_hooked_nav['PLUGIN_COMMENTS.COMMENTS'] = ['route' => $this->route, 'icon' => 'fa-file-text']; } /** * Exclude comments from the Data Manager plugin */ public function onDataTypeExcludeFromDataManagerPluginHook() { $this->grav['admin']->dataTypesExcludedFromDataManagerPlugin[] = 'comments'; } }