Как раскидать подкатегории в разные блоки на главной?

Доброго всем!

Не могу понять как в файле шаблона проверить категорию по id и вывести ее потомков в определенный блок в табах.
Подскажите кто может пожалуйста.

<section class="wrap_block">
      <div class="wrap_content-main catalog">
          <div class="zagolovok_katalog">Каталог</div>
          <div class="perekluchatel_katalog">
              <div id="pilomat" class="btn_catalog active">Категория 1</div>
              <div id="metal" class="btn_catalog">Категория 2</div>
          </div>
          <div id="tab_pilomat" class="tab_catalog active">
              {% for category in categories %}
                {% if category.category_id == category_id %} 
                {% if category.children %}
                  {% for child in category.children %}
                    {% if child.category_id == child_id %}
                      <a href="{{ child.href }}" class="list-group-item active">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a> 
                      {% else %}  
                      <a href="{{ child.href }}" class="list-group-item">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a>
                      {% endif %}
                  {% endfor %}
                {% endif %}
                  {% else %} <a href="{{ category.href }}" class="list-group-item">{{ category.name }}</a>
                {% endif %}
              {% endfor %}
          </div>
          <div id="tab_metal" class="tab_catalog">
              {% for category in categories %}
              {% if category.category_id == category_id %} 
              <a href="{{ category.href }}" class="list-group-item active">{{ category.name }}</a> 
              {% if category.children %}
              {% for child in category.children %}
              {% if child.category_id == child_id %}
              <a href="{{ child.href }}" class="list-group-item active">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a> 
              {% else %} 
              <a href="{{ child.href }}" class="list-group-item">&nbsp;&nbsp;&nbsp;- {{ child.name }}</a>
              {% endif %}
              {% endfor %}
              {% endif %}
              {% else %} <a href="{{ category.href }}" class="list-group-item">{{ category.name }}</a>
              {% endif %}
              {% endfor %}
          </div>
      </div>
  </section>
  • Вопрос задан
  • 39 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы