nav.html.twig 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {% set nav_hover = config.plugins.admin.sidebar.activate == 'hover' %}
  2. {% if authorize(['admin.login', 'admin.super']) %}
  3. <nav id="admin-sidebar" data-quickopen="{{ config.plugins.admin.sidebar.activate == 'hover' ? 'true' : 'false' }}" data-quickopen-delay="{{ config.plugins.admin.sidebar.hover_delay }}">
  4. <div id="admin-logo" class="{{ nav_hover ? 'nav-hover' }}">
  5. {% if not nav_hover %}
  6. <div id="open-handle" data-sidebar-toggle><i class="fa fa-angle-right"></i></div>
  7. {% endif %}
  8. {% include 'partials/logo.html.twig' %}
  9. </div>
  10. {% include 'partials/nav-user-details.html.twig' %}
  11. {% include 'partials/nav-quick-tray.html.twig' %}
  12. <div data-simplebar class="admin-menu-wrapper">
  13. <ul id="admin-menu">
  14. {% for label, item in grav.twig.plugins_hooked_nav %}
  15. {% set route = (item.route ?? item.location)|trim('/') %}
  16. {% set location = (item.location ?? item.route)|trim('/') ~ '/' %}
  17. {% set auth_rule = item.authorize is iterable ? item.authorize : [item.authorize ?: 'admin.' ~ route, 'admin.super'] %}
  18. {% if authorize(auth_rule) %}
  19. <li class="{{ nav_route|starts_with(location) ? 'selected' : '' }}">
  20. <a href="{{ admin_route(route) }}">
  21. <i class="fa fa-fw {{ item.icon }}"></i>
  22. <em>{{ label|t }}</em>
  23. {% set badge = item.badge ?? null %}
  24. {% if badge %}
  25. <span class="badges {% if badge.updates %}with-updates{% endif %}">
  26. {% if badge.updates is defined %}<span class="badge updates">{{ badge.updates ?: '' }}</span>{% endif %}
  27. <span class="badge count">{{ badge.count }}</span>
  28. </span>
  29. {% endif %}
  30. </a>
  31. </li>
  32. {% endif %}
  33. {% endfor %}
  34. {% include 'partials/nav-pro.html.twig' ignore missing %}
  35. <li>
  36. <a href="{{ uri.addNonce(base_url_relative ~ '/task' ~ config.system.param_sep ~ 'logout', 'logout-form', 'logout-nonce') }}"><i class="fa fa-fw fa-sign-out"></i><em>{{ "PLUGIN_ADMIN.LOGOUT"|t }}</em></a>
  37. </li>
  38. </ul>
  39. </div>
  40. </nav>
  41. {% endif %}