Jump to content

Zwinięte kategorie


pawelindustry

Recommended Posts

Mam następujący problem w swoim sklepie.

Mimo różnych kombinacji nie udaje mi się uzyskać efektu, by na stronie kategorii, pod nawigacją pojawiały się wszystkie kategorie, z czego bieżąca kategoria byłaby rozwinięta, pokazując podkategorie. Kombinowałem różne rozwiązania wynikające z ustawień szablonu Optima, jednakże bez efektu.  Za wszelką pomoc będę bardzo wdzięczny. 

Kod ps_categorytree.tpl wygląda następująco:
 

{function name="categories" nodes=[] depth=0}
  {strip}
    {if $nodes|count}
      <ul class="category-sub-menu">
        {foreach from=$nodes item=node}
  <li data-depth="{$depth}" class="{if isset($currentCate) && ($node.id == $currentCate || in_array($currentCate, array_column($node.children, 'id')))} active{/if}">
    {if $depth === 0}
      <a href="{$node.link}">{$node.name}</a>
      {if $node.children}
        <div class="navbar-toggler collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="true">
          <i class="material-icons add">&#xE145;</i>
          <i class="material-icons remove">&#xE15B;</i>
        </div>
        <div class="collapse show always-open" id="exCollapsingNavbar{$node.id}">
          {categories nodes=$node.children depth=$depth+1}
        </div>
      {/if}
    {else}
      <a class="category-sub-link" href="{$node.link}">{$node.name}</a>
      {if $node.children}
        <span class="arrows collapse-icons" data-toggle="collapse" data-target="#exCollapsingNavbar{$node.id}" aria-expanded="true">
          <i class="material-icons add">&#xE145;</i>
          <i class="material-icons remove">&#xE15B;</i>
        </span>
       <div class="collapse show" id="exCollapsingNavbar{$node.id}">
          {categories nodes=$node.children depth=$depth+1}
        </div>
      {/if}
    {/if}
  </li>
{/foreach}
      </ul>
    {/if}
  {/strip}
{/function}

<div class="block-categories">
  <ul class="category-top-menu">
    {if $categories.id == '2'}
      <li><a class="text-uppercase h6" href="{$categories.link nofilter}">{l s='Product categories' d='Modules.Categorytree.Shop'}</a></li>
    {else}
      <li><a class="text-uppercase h6" href="{$categories.link nofilter}">{$categories.name}</a></li>
    {/if}
    
    <li>{categories nodes=$categories.children}</li>
  </ul>
</div>

 

Link to comment
Share on other sites

Ten kod jest oryginalnie z szablonu czy już po przeróbkach? Skąd tam jest $currentCate ? Nie powinno być czasem $currentCategory ? To po pierwsze po drugie nie wiem czy tylko to wystarczy czy ten warunek nie trzeba będzie ująć jeszcze w innym miejscu.

Link to comment
Share on other sites

Sprawdziłem demo i odkryłem, że klasa aktywna jest stosowana do bieżącej kategorii, która stosuje efekt.

 

image.thumb.png.4b9c80871048dbf3b06022f09d826f3b.png

 

 

Chociaż nie jest to dostępne w twoim przypadku

image.thumb.png.3f10ff80b5666cf98a82cb6b9dddc9c2.png

 

Zatem ten warunek nie działa, co dodaje klasę "aktywną".

  <li data-depth="{$depth}" class="{if isset($currentCate) && ($node.id == $currentCate || in_array($currentCate, array_column($node.children, 'id')))} active{/if}">

 

Zatem problem może wynikać z $currentCate.

 

Edited by Knowband Plugins (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...