Announcement

Collapse
No announcement yet.

Category Tree > Display Top Categories Only

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

    Category Tree > Display Top Categories Only

    Is there already a dozen posts about this subject? yep. Ive searched them out and read them all. Do any of them have some sort of descriptive resolution? not really. They seem to either be unanswered, told to use CSS (Which was a terrible idea), resolved with an "I figured it out, never mind" post or the most logical, ""Toolkit does that"

    Problem is, Ive looked at my code vs. the toolkit code for an hour and I can seem to sort it all out. Its been a chore for me to figure out how to understand the mvt statements, but breaking them up with toolkit code still confuses me even more.

    here is my Cat Tree Code:

    Code:
    <div id="category-tree">
    <mvt:foreach array="cattree_categories" iterator="cattree_category">
        <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id">
       
        <div class="level-&mvte:cattree_category:level; active">
        <mvt:elseif expr="NOT ISNULL g.Category_Code AND ISNULL l.settings:category:id AND l.settings:cattree_category:code EQ g.Category_Code">
        <div class="level-&mvte:cattree_category:level; active">
        <mvt:else>
        <div class="level-&mvte:cattree_category:level;">
        </mvt:if>
            <a href="&mvte:cattree_category:link;">
            <mvt:if expr="l.settings:cattree_category:image">
            <img src="&mvte:cattree_category:image;" alt="&mvte:cattree_category:name;" />
            <mvt:else>
            &mvte:cattree_category:name;
            </mvt:if>
            </a>
        </div>
    </mvt:foreach>
    </div>
    unfortunately all can find in the toolkit examples is how to expand all category levels.
    What am I missing?
    Last edited by neuroticartist; 12-19-13, 11:38 AM.

    #2
    Re: Category Tree &gt; Display Top Categories Only

    The answer lies in l.settings:cat tree_category:level, which basically represents each level of the category structure within the category tree. Down and dirty example:

    HTML Code:
    <mvt:foreach array="cattree_categories" iterator="cattree_category">
    <mvt:if expr="l.settings:cattree_category:level EQ 0">
    Top level cats
    </mvt:if>
    </mvt:foreach>

    Comment


      #3
      Re: Category Tree &gt; Display Top Categories Only

      Hi Dan, thanks for that info, unfortunately it isnt enough info for me to figure it all out, nothing I did worked. The only "category:level" in my code above is "div class="level-&mvte:cattree_category:level; active" and its a div class. whats the difference between EQ 0 and ACTIVE? switching them out didnt work.

      Comment


        #4
        Re: Category Tree &gt; Display Top Categories Only

        *Bump* Hi, anyone have any suggestion how I can make this work? So far I have not been able to hide second or third level categories.

        Comment


          #5
          Re: Category Tree &gt; Display Top Categories Only

          Here's what I think Dan was trying to get you:

          Code:
          <div id="category-tree">
          <mvt:foreach array="cattree_categories" iterator="cattree_category">
              
              <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id">   
              	<div class="level-&mvte:cattree_category:level; active">
              <mvt:elseif expr="NOT ISNULL g.Category_Code AND ISNULL l.settings:category:id AND l.settings:cattree_category:code EQ g.Category_Code">
              	<div class="level-&mvte:cattree_category:level; active">
              <mvt:else>
          	    <div class="level-&mvte:cattree_category:level;">
              </mvt:if>
              
              <mvt:if expr="l.settings:cattree_category:level EQ 0">
          
                  <a href="&mvte:cattree_category:link;">
          
                  <mvt:if expr="l.settings:cattree_category:image">
          	        <img src="&mvte:cattree_category:image;" alt="&mvte:cattree_category:name;" />
                  <mvt:else>
          	        &mvte:cattree_category:name;
                  </mvt:if>
                  </a>
          
          	</mvt:if>
          
              </div>
          </mvt:foreach>
          </div>
          (Note: Folks like Dan and I are always happy to help as much as we can, but we do make our living doing this, so its often hard to take the additional time to actually hand over "plug and play" code. (Its also hard cause we don't see the context nor have time to look at the context all the time.)
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            Re: Category Tree &gt; Display Top Categories Only

            Hi Bruce and thank you for your assistance. I totally understand the situation and I am very appreciative of all the assistance I get here form you guys. Since Im still learning how MIVA works, sometimes a lead in the right direction reveals many fruitful results, other times, its almost enough info for me to start to understand, while other times, I am unable to figure out the key element that I'm missing to make things function correctly. Each time I start to figure out how things work in the larger context and sometimes I want to go a little further to make sure I understand. Its all an uphill process but I am grateful for all the help that I do get. :)

            I will give this a try and post back with my results. thanks!

            Comment


              #7
              Re: Category Tree &gt; Display Top Categories Only

              Note: Folks like Dan and I are always happy to help as much as we can, but we do make our living doing this, so its often hard to take the additional time to actually hand over "plug and play" code. (Its also hard cause we don't see the context nor have time to look at the context all the time.
              I definitely refrain from giving the answer/exact code these days because my time, knowledge and experience has to be worth something, or I don't make a living. I try to nudge people in the right direction or provide them with resources they can learn from. (http://glendaledesigns.com/knowledge...ant-resources/)

              I have also found that many do not learn if the code is provided to them. They tend to simply implement the snippet and move on, never taking the time to understand the mechanisms and logic that made the solution work. This often results in repeat requests down the road for similar solutions.

              That all said, Bruce will be the first to tell you that I am an evil capitalist as well, so take my comments through a filter ;)

              Comment


                #8
                Re: Category Tree &gt; Display Top Categories Only

                Damn, looks like i was second that time Dan, way to steal work from from me :)
                Bruce Golub
                Phosphor Media - "Your Success is our Business"

                Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                phosphormedia.com

                Comment


                  #9
                  Re: Category Tree &gt; Display Top Categories Only

                  Well I appreciate the pushes in the right direction but that was a bust. All that code did was crash my nav tree and just show the divider lines (no cat links at all).

                  I compared the code line for line and Ive tried to figure out the difference and why but I just dont have enough background with this code and Im spending tons of time trying to decipher it without understanding how it works.

                  Theres a dozen posts about this subject on the forum and none of them actually work or are resolved. Im just gonna have to move on. thanks anyway guys. perhaps I will revisit this when I understand the code better.

                  Comment


                    #10
                    Re: Category Tree &gt; Display Top Categories Only

                    Change the following line to check for "1" vs. "0". (for some reason I had it in my head that the top level fired as zero, pretty sure it was that way at one point in time)

                    Code:
                    <mvt:if expr="l.settings:cattree_category:level EQ 0">

                    Comment


                      #11
                      Re: Category Tree &gt; Display Top Categories Only

                      yeah I did try that and what it does is shows the top level but doesnt hide the lines for the 2nd levels. much like a CSS display: none; tag

                      Comment


                        #12
                        Re: Category Tree &gt; Display Top Categories Only

                        What's the store URL?
                        Leslie Kirk
                        Miva Certified Developer
                        Miva Merchant Specialist since 1997
                        Previously of Webs Your Way
                        (aka Leslie Nord leslienord)

                        Email me: [email protected]
                        www.lesliekirk.com

                        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                        Comment


                          #13
                          Re: Category Tree &gt; Display Top Categories Only

                          http://lightparts.mivamerchant.net/

                          the original code is back up

                          Comment


                            #14
                            Re: Category Tree &gt; Display Top Categories Only

                            The reason its hard to provide cut and paste code (aside from our evil capitalist desires :) )is because that code works with variables. Variables, but nature can change based on other conditions. So, without being able to look at through a specific site's admin, small things could be off.
                            Bruce Golub
                            Phosphor Media - "Your Success is our Business"

                            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                            phosphormedia.com

                            Comment


                              #15
                              Re: Category Tree &gt; Display Top Categories Only

                              no problem at all I understand. I'll PM you. thanks!

                              Comment

                              Working...
                              X