I'm trying to create an ocmod for the admin panel. Basically, I want to add 2 buttons in the dashboard sidebar but only visible for users with administrator permissions.
How can I achieve that?
Note the custom views and controllers are ready.
CodePudding user response:
If you want to change anything in client page via login in admin panel as admin - can use this solution
In any controller you need add following:
if (isset($this->session->data['user_id']) && $this->session->data['user_id']) {
$data['admin'] = true;
} else {
$data['admin'] = false;
}
Than in same controller's twig:
{% if admin %}
buttons on client side if admin is logged in in panel on the same browser
{% endif %}