Announcement

Collapse
No announcement yet.

Exclude specific categories from category tree

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

    Exclude specific categories from category tree

    An easy way to exclude specific categories from appearing in the category tree.

    Please.

    Thank you.

    #2
    Maybe this doesn't do what you want, but you can always just assign them to a top level category that is set to inactive.
    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


      #3
      Thank you, Bruce!
      That seems to work. The category will appear in the category tree while on that category page, but I don't think that will be a problem.

      Comment


        #4
        It shouldn't show up if its set to 'Inactive'
        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


          #5
          The parent category is set to inactive and does not show up in the category tree. But the active sub-category does appear in the category tree on that sub-category page only.

          Comment


            #6
            Then you'd need to modify the code in the category tree template. How to do that would depend on what you actually wanted to display in that area of your site when you are looking at the sub-categories.
            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


              #7
              Right .... and that's why I created this post under Dream Features ... for Miva to provide an easier way (ie without modifying code) to exclude categories/sub-categories from the category tree. Similar to excluding Navigation Items in a Ready Theme Navigation Set. We can dream, can't we? :-)

              Comment


                #8
                Would a ReadyTheme Navigation Set work here? It would replace the default category tree and you get to manually assign/unassign the what categories you want to show up.

                https://docs.miva.com/videos/readytheme-nav-sets

                Brennan Heyde
                VP Product
                Miva, Inc.
                [email protected]
                https://www.miva.com

                Comment


                  #9
                  Although this will require some initial coding changes, You shouldn't have to deal with code once it is set up properly.

                  You can achieve what you are looking for by using a Custom Category Field.

                  Custom Field Set Up
                  1. Navigate to Settings > Utilities > Custom Fields
                  2. Click "New Custom Field"
                  3. Use the following settings
                    1. Type: Category Field
                    2. Code: exclude_cat_cattree
                    3. Name: Exclude From Cattree
                    4. Field Type: Checkbox
                    5. Additional Information: check this box to exclude category from category tree (this is not required but can be a helpful internal hint for you or your employees)
                    6. Click Add
                  4. Navigate to the Category you want to exclude and click the Category Name
                  5. Go to the "Custom Fields" Tab and Check the box for the new "Exclude From Cattree" custom field you just created
                  6. Click Update
                  7. Repeat steps 4-6 to exclude as many Categories as you want
                  Category Tree Code
                  1. Navigate to User Interface > Global Settings and scroll to the Category Tree Template
                  2. Below the Template is a Section Called "Custom Fields"
                    1. In the left hand box there is a list of all of your Custom Category Fields for your store
                    2. Find the "Exclude From Cattree" custom field and click on it so it is highlighted in blue
                    3. Click the "Select" button and you will see that selected custom field now appears in the right hand box
                  3. Wrap your category tree conditionals for the links with the conditional code in red. Make sure all category tree conditionals are within this conditional and make sure the conditional is inside the foreach iterator
                    Code:
                     <mvt:foreach array="cattree_categories" iterator="cattree_category">
                      <mvt:if expr="l.settings:cattree_category:customfield_values:customfields:exclude_cat_cattree NE '1'">
                    	      <mvt:if expr="l.settings:cattree_category:level EQ 1">
                    	          <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id">
                    	              <li class="level-&mvte:cattree_category:level;"><a class="bold current-item" href="&mvte:cattree_category:link;">&mvt:cattree_category:name;</a></li>
                    	          <mvt:else>
                    	              <li class="level-&mvte:cattree_category:level;"><a href="&mvte:cattree_category:link;">&mvt:cattree_c ategory:name;</a></li>
                    	          </mvt:if>
                    	      <mvt:elseif expr="l.settings:cattree_category:level EQ 2">
                    	          <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id">
                    	              <li class="level-&mvte:cattree_category:level;"><a class="bold current-item" href="&mvte:cattree_category:link;">&mvt:cattree_category:name;</a></li>
                    	          <mvt:else>
                    	              <li class="level-&mvte:cattree_category:level;"><a href="&mvte:cattree_category:link;">&mvt:cattree_c ategory:name;</a></li>
                    	          </mvt:if>
                    	      <mvt:else>
                    	          <mvt:if expr="NOT ISNULL l.settings:category:id AND l.settings:category:id EQ l.settings:cattree_category:id">
                    	              <li class="level-&mvte:cattree_category:level;"><a class="bold current-item" href="&mvte:cattree_category:link;">&mvt:cattree_category:name;</a></li>
                    	          <mvt:else>
                    	              <li class="level-&mvte:cattree_category:level;"><a href="&mvte:cattree_category:link;">&mvt:cattree_category:name;</a></li>
                    	          </mvt:if>
                    	      </mvt:if>
                      </mvt:if>
                    	</mvt:foreach>
                  4. Click Update


                  In Miva the value of a custom field checkbox is 1 if it is checked.

                  So what that conditional is doing is checking to see if the value of the exclude_cat_cattree custom field does NOT EQUAL 1.

                  So if it does NOT EQUAL 1 (exclude_cat_cattree checkbox IS NOT checked), then it will display the category link in the category tree.

                  If it does equal 1 (exclude_cat_cattree checkbox IS checked), then it will not show the categgory link in the category tree.



                  I tested this in our store's Developer Template Branch and it does indeed work.

                  Hopefully this helps you and anyone else looking for the same functionality.

                  Cheers,

                  Nick
                  Last edited by SidFeyDesigns; 09-08-22, 02:32 PM.
                  Nick Harkins
                  www.loveisarose.com
                  *Web Developer
                  *Miva
                  *Google Analytics, Search Console, Tag Manager, Merchant Center, Ads

                  Comment


                    #10
                    Hi Nick.
                    Awesome!! Thank you so much for sharing this with us! It works perfectly!

                    Thank you!!
                    Ron

                    Comment


                      #11
                      Originally posted by QuickRon View Post
                      Hi Nick.
                      Awesome!! Thank you so much for sharing this with us! It works perfectly!

                      Thank you!!
                      Ron
                      Not a problem! Glad you were able to get it set up!
                      Nick Harkins
                      www.loveisarose.com
                      *Web Developer
                      *Miva
                      *Google Analytics, Search Console, Tag Manager, Merchant Center, Ads

                      Comment

                      Working...
                      X