templates/front/components/navbar.twig line 1

Open in your IDE?
  1. <div class="container-fluid">
  2.     <header class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom">
  3.         {% if app.request.get('_route_params')['slug'] is defined %}
  4.             {% set active_page = app.request.get('_route_params')['slug'] %}
  5.         {% else %}
  6.             {% set active_page = 'homepage' %}
  7.         {% endif %}
  8.         <a href="/" class="d-flex align-items-center col-md-2 mb-2 mb-md-0 text-dark text-decoration-none">
  9.             <img src="{{ asset('build/img/ferme_logo.png') }}" alt="" class="bi me-2" id="logo-navbar" role="img">
  10.         </a>
  11.         <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
  12.             {% for item in generateMenu() %}
  13.                 {% if item.children is empty and item.parent is null %}
  14.                     <li class="nav-item px-2 ms-4">
  15.                         <a href="{{ path('app_page_show', {'slug': item.slug}) }}" class="nav-link px-4 {% if item.slug is same as active_page %}active{% endif %}">
  16.                             <strong>
  17.                                 {{ item.title }}
  18.                             </strong>
  19.                         </a>
  20.                     </li>
  21.                 {% elseif item.children is not empty %}
  22.                     <li class="nav-item dropdown px-2 ms-4">
  23.                         <a href="#" data-bs-toggle="dropdown" class="nav-link dropdown-toggle px-4">
  24.                             <strong>{{ item.title }}</strong>
  25.                         </a>
  26.                         <div class="dropdown-menu">
  27.                             {% for children in item.children %}
  28.                                 {% if children.online == '1' %}
  29.                                     <a href="{{ path('app_page_show', {'slug': children.slug}) }}" class="dropdown-item">
  30.                                         <strong>
  31.                                             {{ children.title }}
  32.                                         </strong>
  33.                                     </a>
  34.                                 {% endif %}
  35.                             {% endfor %}
  36.                         </div>
  37.                     </li>
  38.                 {% endif %}
  39.             {% endfor %}
  40.         </ul>
  41.         <div class="col-md-2 text-end">
  42.             {% if is_granted('ROLE_USER') %}
  43.                 <a href="{{ path('app_logout') }}" type="button" 
  44.                    class="btn btn-outline-primary btn-sm me-2">
  45.                     Déconnexion
  46.                 </a>
  47.                 <a href="{{ path('app_user_show', {'id': app.user.id}) }}" type="button" 
  48.                     class="btn btn-outline-primary btn-sm me-2">
  49.                     Votre profil
  50.                 </a>
  51.             {% elseif is_granted('ROLE_ADMIN')   %}
  52.                 <a href="{{ path('app_logout') }}" type="button" 
  53.                     class="btn btn-outline-primary btn-sm me-2">
  54.                     Logout
  55.                 </a>
  56.                 <a href="{{ path('easyadmin') }}" type="button" 
  57.                     class="btn btn-outline-primary btn-sm me-2">
  58.                     > Admin
  59.                 </a>
  60.             {% else %}
  61.                 <a href="{{ path('app_login') }}" type="button" 
  62.                 class="btn btn-outline-primary btn-sm me-2">
  63.                     Se connecter
  64.                 </a>
  65.                 <a href="{{ path('app_register') }}" type="button" 
  66.                 class="btn btn-outline-primary btn-sm me-2">
  67.                     Creer un compte
  68.                 </a>
  69.             {% endif %}
  70.         </div>
  71.     </header>
  72. </div>