templates/category/show.html.twig line 1

Open in your IDE?
  1. {% import "macros/product.html.twig" as productMacros %}
  2. {% extends 'base.html.twig' %}
  3. {% block title %}
  4. {{"general.category"|trans ~ " triwu_u" }}
  5. {% endblock %}
  6. {% block mainClass %}pt-32{% endblock %}
  7. {% block login %}{% endblock login %}
  8. {% block content %}
  9.     {% include 'components/header/categories.html.twig' %}
  10.     <aside id="sidebar-mobile" class="z-20 fixed text-sm block w-full tablet:hidden bg-white p-4 overflow-x-auto whitespace-nowrap border-b border-gray-700">
  11.             <ul class="flex">
  12.                 {% for categoryItem in categories %}
  13.                    {%if (category is defined and category is not null and categoryItem.id == category.id )%}
  14.                     <li class="">
  15.                         {# Verificar si la categoría actual es la misma que la del ítem en el loop #}
  16.                         
  17.                         {# Verificar si la categoría tiene subcategorías #}
  18.                         {% set hasSubcategories = categoryItem.subcategories is not empty %}
  19.                         
  20.                         {# Solo mostrar el detalle si la categoría tiene subcategorías #}
  21.                         {% if hasSubcategories %}
  22. {#
  23.                                 <li 
  24.                                     class="cursor-pointer p-2 rounded no-arrow text-xs
  25.                                     {% if isCurrentCategory %}
  26.                                         text-black font-bold hover:text-white
  27.                                     {% else %}
  28.                                         text-black hover:text-white no-arrow 
  29.                                     {% endif %}
  30.                                     ">
  31.                                     <a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}" 
  32.                                     class="uppercase">
  33.                                         {{ categoryItem.name | upper }}
  34.                                     </a>
  35.                                 </li>
  36. #}
  37.                                     {% for subcategoryB in categoryItem.subcategories %}
  38.                                         {% set isCurrentSubCategory = false%}
  39.                                         {% if (subcategory is defined and subcategory is not null  and subcategoryB.id == subcategory.id) %}
  40.                                             {% set isCurrentSubCategory = true%}
  41.                                         {%endif%}
  42.                                         <li class="text-sm hover:bg-primary/10 {% if isCurrentSubCategory %}!bg-primary/10{%endif%}" >
  43.                                             <a href="{{ path('product_category_show', {'slug': categoryItem.slug,'subcategorySlug': subcategoryB.slug}) }}" 
  44.                                             class="block p-2 rounded text-xs
  45.                                             {% if (subcategory is defined and subcategory is not null  and subcategoryB.id == subcategory.id) %}
  46.                                                 text-primary hover:text-primary
  47.                                             {% else %}
  48.                                                 text-black hover:text-primary
  49.                                             {% endif %}
  50.                                             ">
  51.                                                 {{ subcategoryB.name | capitalize }}
  52.                                             </a>
  53.                                         </li>
  54.                                     {% endfor %}
  55.                         {% else %}
  56. {#
  57.                             <a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}" 
  58.                             class="block p-2 rounded text-xs
  59.                             {% if isCurrentCategory %}
  60.                                 text-primary font-bold hover:text-primary 
  61.                             {% else %}
  62.                                 text-black hover:text-primary no-arrow 
  63.                             {% endif %}
  64.                             uppercase">
  65.                                 {{ categoryItem.name | upper }}
  66.                             </a>
  67. #}
  68.                         {% endif %}
  69.                     </li>
  70.                     {%endif%}
  71.                 {% endfor %}
  72.             </ul>
  73.         </aside>
  74.     <div class="flex ">
  75.         <!-- Menú vertical de categorías -->
  76.         
  77.         <aside id="sidebar-desktop" class="w-auto hidden desktop:block desktop:w-auto tablet:block  tablet:w-auto bg-white p-4 overflow-y-auto h-screen sticky top-0 border-r border-gray-700">
  78.             <ul class="list-none">
  79.                 {% for categoryItem in categories %}
  80.                     {% set isCurrentCategory = null %}
  81.                     {%if (category is defined and category is not null )%}
  82.                         {% set isCurrentCategory = (categoryItem.id == category.id)%}
  83.                     {%endif%}
  84.                     {% if hasSubcategories is defined%}{%else%}<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}">{%endif%}
  85.                     <li class="pb-2 pt-2 border-b border-gray-300 hover:bg-primary/10 {% if isCurrentCategory %}!bg-primary/10{%endif%}">
  86.                         {# Verificar si la categoría actual es la misma que la del ítem en el loop #}
  87.                         
  88.                         {# Verificar si la categoría tiene subcategorías #}
  89.                         {% set hasSubcategories = categoryItem.subcategories is not empty %}
  90.                         
  91.                         {# Solo mostrar el detalle si la categoría tiene subcategorías #}
  92.                         {% if hasSubcategories %}
  93.                           
  94.                             <div class="group">
  95.                                 <a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}" >
  96.                                 <div class="cursor-pointer p-2 rounded  text-xs {% if isCurrentCategory %} text-primary font-bold hover:text-primary 
  97.                                     {% else %}text-black hover:text-primary {% endif %}
  98.                                     ">
  99.                                     
  100.                                         <span class="uppercase">
  101.                                            {{ categoryItem.name | upper }}
  102.                                         </span>
  103.                                     
  104.                                 </div>
  105.                                 </a>
  106.                                 <ul class="ml-4 {% if isCurrentCategory %}block{%else%}hidden{%endif%}">
  107.                                     {% for subcategoryB in categoryItem.subcategories %}
  108.                                         <li class="text-sm">
  109.                                             <a href="{{ path('product_category_show', {'slug': categoryItem.slug,'subcategorySlug': subcategoryB.slug}) }}" 
  110.                                             class="block p-2 rounded text-xs
  111.                                             {% if (subcategory is defined and subcategory is not null  and subcategoryB.id == subcategory.id) %}
  112.                                                 text-primary hover:text-primary
  113.                                             {% else %}
  114.                                                 text-black hover:text-primary
  115.                                             {% endif %}
  116.                                             ">
  117.                                                 {{ subcategoryB.name | capitalize }}
  118.                                             </a>
  119.                                         </li>
  120.                                     {% endfor %}
  121.                                 </ul>
  122.                             </div>
  123.                             
  124.                         {% else %}
  125.                             <a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}" 
  126.                             class="block p-2 rounded text-xs
  127.                             {% if isCurrentCategory %}
  128.                                 text-primary font-bold hover:text-primary
  129.                             {% else %}
  130.                                 text-black hover:text-primary no-arrow 
  131.                             {% endif %}
  132.                             uppercase">
  133.                                 {{ categoryItem.name | upper }}
  134.                             </a>
  135.                         {% endif %}
  136.                     </li>{% if hasSubcategories is defined%}{%else%}</a>{%endif%}
  137.                 {% endfor %}
  138.             </ul>
  139.         </aside>
  140.         <section class="mobile:mt-20 relative tablet:max-w-screen-xl mx-auto mb-12 px-edge ">
  141.             <section class="space-y-3 pt-2">
  142.                 {% if subcategory is defined and subcategory is not null %}
  143.                     <h5><a href="{{ path('app_index') }}" class="hover:text-primary">{{'general.categorias' | trans}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug}) }}" class="hover:text-primary">{{category.name | capitalize}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug,'subcategorySlug': subcategory.slug}) }}" class="text-primary">{{subcategory.name | capitalize}}</a></h5>
  144.                 {%else%}
  145.                     <h5><a href="{{ path('app_index') }}" class="hover:text-primary">{{'general.categorias' | trans}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug}) }}" class="text-primary">{{category.name | capitalize}}</a></h5>
  146.                 {%endif%}
  147.                 <h3 class="text-2xl tablet:text-3xl">
  148.                     <span class="font-bold">{{ subcategory is defined and subcategory is not null ? subcategory.name : category.name }}</span>
  149.                 </h3>
  150.     {#
  151.                 {{ form_start(searchForm) }}
  152.                     {{ form_row(searchForm.province) }}
  153.                     <button type="submit">Filtrar</button>
  154.                 {{ form_end(searchForm) }}
  155.     #}
  156.                 <div class="pb-edge grid gap-3 grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 tablet:gap-6 relative z-10">
  157.                     {% for product in products %}
  158.                         {{ productMacros.productCard(product,groupsProducts) }}
  159.                     {% endfor %}
  160.                 </div>
  161.             </section>
  162.         </section>
  163.     </div>
  164.     <div id="ConfirmProduct" data-modal="confirmProduct" tabindex="-1" aria-hidden="true" class="modal-app">
  165.         <div class="modal-app__backdrop"></div>
  166.         <div class="modal-app__container">
  167.             <div class="modal-app__content">
  168.                 <header>
  169.                     <h3 class="text-xl font-bold desktop:text-2xl">
  170.                         {{ "product.confirm.title" | trans }} 
  171.                     </h3>
  172.                 </header>
  173.                 <main class="leading-5 mt-3 mb-4">
  174.                     <p>{{ "product.confirm.desc" | trans }} </p>
  175.                 </main>
  176.                 <a href="{{ path('app_product_add_to_shopping_cart', {'id': '#', 'isIndividual': false, 'newCart': true}) }}" class="ConfirmButton btn btn--primary btn--md btn-buy product-card__price-block__btn">
  177.                     {{ "product.confirm.btn" | trans }} 
  178.                 </a>
  179.                 <button id="CloseConfirmProduct" type="button" class="btn btn--md w-full mt-1">
  180.                     {{ "product.confirm.cancel" | trans }} 
  181.                 </button>
  182.             </div>
  183.         </div>
  184.     </div>
  185. {% endblock %}