mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-11 15:56:06 +01:00
Call onAdminTemplateNavPluginHook to provide plugins the ability to populate plugins_hooked_nav
Example event handling:
public function onAdminTemplateNavPluginHook()
{
$this->grav['twig']->plugins_hooked_nav['PLUGIN_DATA.DATA'] =
['route' => 'data', 'icon' => 'fa-file-text'];
}
This commit is contained in:
@@ -223,6 +223,9 @@ class AdminPlugin extends Plugin
|
|||||||
$twig->twig_vars['base_path'] = GRAV_ROOT;
|
$twig->twig_vars['base_path'] = GRAV_ROOT;
|
||||||
$twig->twig_vars['admin'] = $this->admin;
|
$twig->twig_vars['admin'] = $this->admin;
|
||||||
|
|
||||||
|
// Gather Plugin-hooked nav items
|
||||||
|
$this->grav->fireEvent('onAdminTemplateNavPluginHook');
|
||||||
|
|
||||||
switch ($this->template) {
|
switch ($this->template) {
|
||||||
case 'dashboard':
|
case 'dashboard':
|
||||||
$twig->twig_vars['popularity'] = $this->popularity;
|
$twig->twig_vars['popularity'] = $this->popularity;
|
||||||
|
|||||||
@@ -31,6 +31,15 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if grav.twig.plugins_hooked_nav %}
|
||||||
|
{% for label, item in grav.twig.plugins_hooked_nav %}
|
||||||
|
<li class="{{ (location == item.route) ? 'selected' : '' }}">
|
||||||
|
<a href="{{ base_url_relative }}/{{ item.route }}">
|
||||||
|
<i class="fa fa-fw {{ item.icon }}"></i> {{ label|tu }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
<li class="{{ (location == 'plugins') ? 'selected' : '' }}">
|
<li class="{{ (location == 'plugins') ? 'selected' : '' }}">
|
||||||
<a href="{{ base_url_relative }}/plugins">
|
<a href="{{ base_url_relative }}/plugins">
|
||||||
<i class="fa fa-fw fa-plug"></i> {{ "PLUGIN_ADMIN.PLUGINS"|tu }}
|
<i class="fa fa-fw fa-plug"></i> {{ "PLUGIN_ADMIN.PLUGINS"|tu }}
|
||||||
|
|||||||
Reference in New Issue
Block a user