Announcement

Collapse
No announcement yet.

Category and Subcategory as unordered list (nested lists)

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

    Category and Subcategory as unordered list (nested lists)

    All-

    I've seen a few threads on this, but nothing seemed to quite have it right with any code examples (at least not that I could find). What I am trying to do is create the category list as an unordered list where the subcategories are then unordered lists of their own. I think I'm somewhat close, but not quite there. Below is what I have so far:

    Code:
    <mvt:if expr="l.settings:cattree:stack EQ 0">
    <mvt:item name="category_tree" param="cattree_header" />
    </mvt:if>
    <mvt:if expr="l.settings:nextcount GT 0">
    
    
    <mvt:if expr="l.settings:cattree:stack GT 0">
    <ul style="padding: 0 0 0 10px;">
    <mvt:else>
    
    </mvt:if>
    <mvt:item name="category_tree" param="nextlevel">
    <mvt:foreach iterator="cattree_category" array="categories">
    <mvt:if expr="l.settings:cattree_category:code EQ g.Category_code">
    <mvt:if expr="NOT l.settings:cattree_category:image">
    <li><strong>&mvt:cattree_category:name;</strong></li>
    <mvt:else>
    <img src="&mvte:cattree_category:image;" alt="&mvte:cattree_category:name;" border=0>
    </mvt:if>
    <mvt:else>
    <li><a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:cattree_category:code;">&mvt:cattree_category:name;</a>
    </mvt:if>
    </li>
    <mvt:if expr="l.settings:cattree_category:id EQ l.settings:cattreenext">
    <mvt:item name="category_tree"/>
    </mvt:if>
    </mvt:foreach>
    </mvt:item>
    <mvt:if expr="l.settings:cattree:stack GT 0">
    </ul>
    <mvt:else>
    
    </mvt:if>
    
    
    </mvt:if>
    <mvt:if expr="l.settings:cattree:stack EQ 0">
    <mvt:item name="category_tree" param="cattree_footer" />
    </mvt:if>
    If you want to see an example, check this out:

    http://www.finfeather.com/Merchant2/...gory_Code=HUNT

    It seems to work ok, but it isn't quite perfect where the sub-list is between the opening and closing LI tags of the list that precedes it. Picky, I know.

    It is set up so that the top level opening and closing UL tags are actually in the Category Tree Template header and footer. Some misc. list items are in there as well (non-MM pages, Account login, etc.). Does anyone have any suggestions on how I can refine this? I would think lots of people have tackled this before and probably have more insight into Miva's code than I do.

    Thanks in advance.

    -Bill

    #2
    Re: Category and Subcategory as unordered list (nested lists)

    Try this (it's pared down, uses short links, and doesn't have provisions for images, so you'll have to tweak it):

    Code:
    <mvt:if expr="l.settings:cattree:stack EQ 0">
    <mvt:item name="category_tree" param="cattree_header" />
    </mvt:if>
    <mvt:if expr="l.settings:nextcount GT 0">
    
    <mvt:comment>Assign id and class to top level list only</mvt:comment>
    <mvt:if expr="l.settings:cattree:stack EQ 0">
    <ul id="myid" class="myclass">
    <mvt:else>
    <ul>
    </mvt:if>
    <mvt:item name="category_tree" param="nextlevel">
    <mvt:foreach iterator="cattree_category" array="categories">
    
    <mvt:comment>Test for subcategories -- if none, close list item, otherwise, close list item in cattreenext conditional</mvt:comment>
    <mvt:if expr="l.settings:cattree_category:code EQ g.Category_code">
    <li><a href="/c/&mvta:cattree_category:code;.html" class="current">&mvt:cattree_category:name;</a>
    <mvt:if expr="l.settings:cattree_category:id NE l.settings:cattreenext"></li></mvt:if>
    <mvt:else>
    <li><a href="/c/&mvta:cattree_category:code;.html">&mvt:cattree_category:name;</a>
    <mvt:if expr="l.settings:cattree_category:id NE l.settings:cattreenext"></li></mvt:if>
    </mvt:if>
    <mvt:if expr="l.settings:cattree_category:id EQ l.settings:cattreenext">
    <mvt:item name="category_tree"/>
    </li>
    </mvt:if>
    </mvt:foreach>
    </ul>
    </mvt:item>
    </mvt:if>
    <mvt:if expr="l.settings:cattree:stack EQ 0">
    <mvt:item name="category_tree" param="cattree_footer" />
    </mvt:if>

    Comment


      #3
      Re: Category and Subcategory as unordered list (nested lists)

      Wow! Thanks. I actually don't want anything for images, so that should work fine. I'll kick the tires on it later and let you know what I think.

      Thanks again!

      -Bill

      Comment

      Working...
      X