Announcement

Collapse
No announcement yet.

Display sub-sub-categories

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

  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post

    You may need to:

    #1 NULL the l.settings:sub_cat:id, l.settings:sub_sub_cat:id, and l.settings:subsubcats 's before each loop
    #2 Wrap in a conditional for l.setting:subsubcats ISNOT NULL.

    (it's a context issue, as I've used this dozens of times, but it's not something that 'drop in' code would suffice. and by default, doing this as a module call would NULL the previous values
    I miss Bill, at least he had examples I could break:

    http://www.emporiumplus.com/v5/tk_tree2.txt



    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Originally posted by lesliekirk View Post
    Well, that didn't work. I produced somewhat similar results as previously mentioned. This time the instead of having the 4 subcategories with all of the parent categories listed below each one, now I have one subcategory with the parent categories followed by 3 more "groups" of the parent categories.

    It's truly not wanting to load the sub sub categories.
    You may need to:

    #1 NULL the l.settings:sub_cat:id, l.settings:sub_sub_cat:id, and l.settings:subsubcats 's before each loop
    #2 Wrap in a conditional for l.setting:subsubcats ISNOT NULL.

    (it's a context issue, as I've used this dozens of times, but it's not something that 'drop in' code would suffice. and by default, doing this as a module call would NULL the previous values

    Leave a comment:


  • lesliekirk
    replied
    It's a bit different than assigning the products to the category. Take a look at this link. It was built with the EmporiumPlus Toolkit.

    Leave a comment:


  • William Davis
    replied
    Originally posted by lesliekirk View Post
    Well, that didn't work. I produced somewhat similar results as previously mentioned. This time the instead of having the 4 subcategories with all of the parent categories listed below each one, now I have one subcategory with the parent categories followed by 3 more "groups" of the parent categories.

    It's truly not wanting to load the sub sub categories.
    Leslie, you mean something like this?

    https://tinyurl.com/y5nyvfcq

    Leave a comment:


  • lesliekirk
    replied
    Well, that didn't work. I produced somewhat similar results as previously mentioned. This time the instead of having the 4 subcategories with all of the parent categories listed below each one, now I have one subcategory with the parent categories followed by 3 more "groups" of the parent categories.

    It's truly not wanting to load the sub sub categories.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied

    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:sub_category:code.Category_Code, l.settings:sub_category:code )" /> s/b
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:subcats:code, l.settings:subsub_category )" /> <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:subsub_category:id, l.settings:subsubcats )" /> <mvt:foreach iterator="subbies" array="subsubcats"> </mvt:foreach>

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    if that's the actual code you are using it still has the typo :
    l.settings:sub_category:code.Category_Code
    Yes, that's the exact code I'm trying to use. Color me confused, but I don't know what your typo is...

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    if that's the actual code you are using it still has the typo :
    l.settings:sub_category:code.Category_Code

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    partially my fault

    l.settings:category:code.Category_Code

    Should be whatever the current parent category code is. in your case that'd be l.settings:sub_category:code...although you might not even need that line as you should check to see if l.settings:sub_category:id is available and just use that in the next line.
    Obviously, I did that wrong too. Now I get EVERY parent category listed below the subcategory name (&mvte:sub_category:name;)
    Code:
    <mvt:foreach array="cattree_categories" iterator="cattree_category">
        <mvt:if expr="l.settings:cattree_category:parent_id EQ l.settings:category:id">
            <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcats, l.settings:cattree_category, -1)" />
        </mvt:if>
    </mvt:foreach>
    <mvt:assign name="l.settings:subcat_count" value="miva_array_elements(l.settings:subcats)" />
    
    <mvt:if expr="l.settings:subcats GT 0 OR l.settings:category_listing:products_on_page_count GT 1">
        <hr class="border--secondary h-nm">
          <mvt:if expr="l.settings:subcats GT 0">
              <section style="padding: 2.625rem 0.75rem; text-align:center; width: 60%; margin: 0 auto;">
                <nav class="cmp-subcategories inline-list secondary-font">
                    <ul>
                        <mvt:foreach iterator="sub_category" array="subcats">
                            <li>
                                <a href="&mvte:sub_category:link;">&mvte:sub_category:name;</a>
    
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:sub_category:code.Category_Code, l.settings:sub_category:code )" />
     <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_sub_category:id, l.settings:subsubcats )" />   
    
                                <ul>
                                  <mvt:foreach iterator="sub_sub_category" array="subsubcats">
                                  <li><a href="&mvte:sub_sub_category:link;">&mvte:sub_sub_category:name;</a></li>
                                      </mvt:foreach>
                              </ul>
                                <!-- // sub-sub-cat -->
                            </li>
                        </mvt:foreach>
                    </ul>
                </nav>
              </section>
                <!-- end .cmp-subcategories -->
            </mvt:if>
        <!-- end .cmp-subcategories-filtering -->
    </mvt:if>

    Leave a comment:


  • lesliekirk
    replied
    Bill's solutions are so much simpler and shorter...is that because his module did all the "heavy lifting" in the background?

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    partially my fault

    l.settings:category:code.Category_Code

    Should be whatever the current parent category code is. in your case that'd be l.settings:sub_category:code...although you might not even need that line as you should check to see if l.settings:sub_category:id is available and just use that in the next line.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    Yes, that's basically where the code I wrote should go. Just make sure you name the array and iterator different from the sub-categories and you'll be fine. You also add a sub-sub-sub-cat if you want...essentially creating a complete category tree. Note: this will, of course, add to processing time.
    LOL - so I tried this

    Code:
    <mvt:foreach array="cattree_categories" iterator="cattree_category">
        <mvt:if expr="l.settings:cattree_category:parent_id EQ l.settings:category:id">
            <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcats, l.settings:cattree_category, -1)" />
        </mvt:if>
    </mvt:foreach>
    <mvt:assign name="l.settings:subcat_count" value="miva_array_elements(l.settings:subcats)" />
    
    <mvt:if expr="l.settings:subcats GT 0 OR l.settings:category_listing:products_on_page_count GT 1">
        <hr class="border--secondary h-nm">
    
            <mvt:if expr="l.settings:subcats GT 0">
              <section style="padding: 2.625rem 0.75rem; text-align:center; width: 60%; margin: 0 auto;">
                <nav class="cmp-subcategories inline-list secondary-font">
                    <ul>
                        <mvt:foreach iterator="sub_category" array="subcats">
                            <li>
                                <a href="&mvte:sub_category:link;">&mvte:sub_category:name;</a>
    
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:category:code.Category_Code, l.settings:current_category )" />
     <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:subsubcats )" />     
    
                                <ul>
                                  <mvt:foreach iterator="sub_sub_category" array="subsubcats">
                                  <li><a href="&mvte:sub_sub_category:link;">&mvte:sub_sub_category:name;</a></li>
                                      </mvt:foreach>
                              </ul>
                                <!-- // sub-sub-cat -->
                            </li>
                        </mvt:foreach>
                    </ul>
                </nav>
              </section>
                <!-- end .cmp-subcategories -->
            </mvt:if>
    
    
    
    
    
    
        <!-- end .cmp-subcategories-filtering -->
    </mvt:if>
    What it gave me was

    A
    A B C D
    B
    A B C D
    C
    A B C D
    D
    A B C D

    I think I didn't do it right




    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Yes, that's basically where the code I wrote should go. Just make sure you name the array and iterator different from the sub-categories and you'll be fine. You also add a sub-sub-sub-cat if you want...essentially creating a complete category tree. Note: this will, of course, add to processing time.

    Leave a comment:


  • lesliekirk
    replied
    I'm wondering how that plays with the CTGY subcategory_listing. I'm wanting to add it where the bold red is at. (I know what is there is wrong, it's just sort of a placeholder for me)


    Code:
        <mvt:foreach array="cattree_categories" iterator="cattree_category">
        <mvt:if expr="l.settings:cattree_category:parent_id EQ l.settings:category:id">
            <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcats, l.settings:cattree_category, -1)" />
        </mvt:if>
    </mvt:foreach>
    <mvt:assign name="l.settings:subcat_count" value="miva_array_elements(l.settings:subcats)" />
    
    <mvt:if expr="l.settings:subcats GT 0 OR l.settings:category_listing:products_on_page_count GT 1">
        <hr class="border--secondary h-nm">
    
            <mvt:if expr="l.settings:subcats GT 0">
              <section style="padding: 2.625rem 0.75rem; text-align:center; width: 60%; margin: 0 auto;">
                <nav class="cmp-subcategories inline-list secondary-font">
                    <ul>
                        <mvt:foreach iterator="sub_category" array="subcats">
                            <li>
                                <a href="&mvte:sub_category:link;">&mvte:sub_category:name;</a>
    <ul>
                                  <mvt:foreach iterator="sub_sub_category" array="subcats">
                                  <li><a href="&mvte:sub_sub_category:link;">&mvte:sub_sub_category:name;</a></li>
                                      </mvt:foreach>
                              </ul>
                                <!-- // sub-sub-cat -->
                            </li>
                        </mvt:foreach>
                    </ul>
                </nav>
              </section>
                <!-- end .cmp-subcategories -->
            </mvt:if>
    
    
        <!-- end .cmp-subcategories-filtering -->
    </mvt:if>

    Or does the "default" code have to be scrapped for something from scratch? Sigh...

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    This:

    Code:
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:category:code.Category_Code, l.settings:current_category )" />
     <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_sub_cat )" /> 
    
     <mvt:foreach iterator="this_cat" array="sub_sub_cat">
       &mvt:this_cat:etc;
    
    </mvt:foreach>
    within the sub_cat foreach will do it.

    Leave a comment:

Working...
X