Announcement

Collapse
No announcement yet.

How to limit category levels in Category Tree on Shadows?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to limit category levels in Category Tree on Shadows?

    I'm on the latest version of Shadows.
    What changes would I make to the Category Tree Template code so that only the top 2 levels of categories (ie parent, child 1) show in the tree?

    Thank you
    Ron


    #2
    Hi Ron,

    Try replacing your category tree code with this:
    Code:
    <nav class="x-category-tree x-collapsible-content" aria-labelledby="categoryTree-label">
    <div class="x-category-tree__title">
    <h3 id="categoryTree-label" class="x-category-tree__heading c-heading-echo u-text-bold u-text-uppercase">Categories</h3>
    <hr class="c-keyline">
    </div>
    <button class="x-category-tree__label x-collapsible-content__toggle u-text-uppercase" data-a11y-toggle="categoryTree" type="button">Categories <span class="u-icon-add" data-toggle="<" aria-hidden="true"></span></button>
    <ul id="categoryTree" class="x-category-tree__row x-collapsible-content__item">
    <mvt:foreach array="cattree_categories" iterator="cattree_category">
    <mvt:if expr="l.settings:cattree_category:level LE 2">
    <li class="x-category-tree__list x-category-tree__list--level-&mvte:cattree_category:level;">
    <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id AND l.settings:page:code NE 'CTLG'">
    <a class="x-category-tree__link x-category-tree__link--current" href="&mvte:cattree_category:link;" title="&mvte:cattree_category:name;">&mvte:cattree _category:name;</a>
    <mvt:elseif expr="NOT ISNULL g.Category_Code AND ISNULL l.settings:category:id AND l.settings:cattree_category:code EQ g.Category_Code AND l.settings:page:code NE 'CTLG'">
    <a class="x-category-tree__link x-category-tree__link--current" href="&mvte:cattree_category:link;" title="&mvte:cattree_category:name;">&mvte:cattree _category:name;</a>
    <mvt:else>
    <a class="x-category-tree__link" href="&mvte:cattree_category:link;" title="&mvte:cattree_category:name;">&mvte:cattree _category:name;</a>
    </mvt:if>
    </li>
    </mvt:if>
    </mvt:foreach>
    </ul>
    </nav>
    <!-- end .x-category-tree -->
    Matt Zimmermann

    Miva Web Developer
    Alchemy Web Development
    https://www.alchemywebdev.com
    Site Development - Maintenance - Consultation

    Miva Certified Developer
    Miva Professional Developer

    https://www.dev4web.net | Twitter

    Comment


      #3
      Hi Matt.
      Thank you for the code. It does limit to the top 2 levels, but every instance of a category in the tree shows _category:name; instead of the category name. How can I fix that?

      Thank you,
      Ron


      Comment


        #4
        Hi Ron,

        Looks like a space was inserted when I pasted the code into the forum. Replace the instances of "&mvte:cattree _category:name;" with "&mvte:cattree_category:name;".
        Matt Zimmermann

        Miva Web Developer
        Alchemy Web Development
        https://www.alchemywebdev.com
        Site Development - Maintenance - Consultation

        Miva Certified Developer
        Miva Professional Developer

        https://www.dev4web.net | Twitter

        Comment


          #5
          Perfect. That fixed it.
          Thank you, Matt!

          Comment

          Working...
          X