Ok, got it!
In user account yaml add:
your_config_name:
config: 'true'
and, under admin, add rights to your page:
your_plugin-page1: 'true'
your_plugin-page2: 'true'
your_plugin-page3: 'true'
your_plugin-page4: 'true'
Then, in plugin's class:
public function onAdminMenu()
{
if ( $this->grav['user']->authorize('your_config_name.config') == 1 ) {
$this->grav['twig']->plugins_hooked_nav['PLUGIN_TRANSLATION.STRING'] = [
'route' => $this->route.'-admin',
'icon' => 'fa-space-shuttle'
];
}
if ( $this->grav['user']->authorize('client.dash') == 1 ) {
$this->grav['twig']->plugins_hooked_nav['PLUGIN_TRANSLATION.STRING'] = [
'route' => $this->route.'-page1',
'icon' => 'fa-dashboard'
];
$this->grav['twig']->plugins_hooked_nav['PLUGIN_TRANSLATION.STRING'] = [
'route' => $this->route.'-page2',
'icon' => 'fa-ambulance'
];
$this->grav['twig']->plugins_hooked_nav['PLUGIN_TRANSLATION.STRING'] = [
'route' => $this->route.'-page3',
'icon' => 'fa-credit-card-alt'
];
$this->grav['twig']->plugins_hooked_nav['PLUGIN_TRANSLATION.STRING'] = [
'route' => $this->route.'-page4',
'icon' => 'fa-briefcase'
];
}
}
where
$this->route = 'your_plugin';
Because of this (in nav.html.twig, Admin plugin):
{% if grav.twig.plugins_hooked_nav %}
{% for label, item in grav.twig.plugins_hooked_nav %}
- {% if authorize(['admin.' ~ item.route, 'admin.super']) %}*
<li class="{{ (location == item.route) ? 'selected' : '' }}">
<a href="{{ base_url_relative }}/{{ item.route }}">
<i class="fa fa-fw {{ item.icon }}"></i>
<em>{{ label|tu }}</em>
</a>
</li>
{% endif %}
{% endfor %}
{% endif %}
Hope this will be useful for someone else!