Announcement

Collapse
No announcement yet.

Issues with the sub-sub-categories display

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

    Issues with the sub-sub-categories display

    Since I'm having a problem with the sub-sub-category display that we all worked on here. I thought it might be best to start a new thread to outline the issue. I do think something similar has come up and I'll dig around to see if I can find it too.

    I have this category page with is using the code for the sub-sub-category display it is repeating a category at the end of the other two categories (all most like it's OCD and is looking for balance). It should be noted that if the other two sub-categories after the first sub-category have more child categories than the first, the issue isn't there as seen here. This category might be the most unique as it shows that only the third sub-category gets the additional child categories added on.


    The first sub-category has 12 child categories assigned to it. The other two sub-categories have 11. But the other two are tacking on a 12th category (the last child category from the first "column") BUT you don't notice it until you are at the end of the list for the other two sub-categories.

    Go to the last category in the Base category list, notice after Microwave Base there is Shelf Wall. It should not be there. Go back to the top and do the same with the Accessories, click Rush Fee. Again, Shelf Wall is someplace it shouldn't be.

    I think something is going on before "Ted's tweak" because it's assigning that category which then generates the products.


    Code:
    <mvt:assign name="l.settings:subcat:id" value=" " />
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( g.Category_Code, l.settings:current_category )" />
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Runtime_CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" />
    <mvt:assign name="l.subcat_count" value="miva_array_elements( l.settings:sub_categories )" />
    <mvt:if expr="l.subcat_count GT 0">
    <mvt:foreach iterator="subcat" array="sub_categories">
    <h2 style="font-size:1.4rem; font-weight:bold;"><a name="&mvt:subcat:code;"></a>&mvte:subcat:name;</h2>
    <mvt:assign name="l.settings:sub_categories2" value=" " />
    <mvt:do name="l.result" file="g.Module_Library_DB" value="Runtime_CategoryList_Load_Parent( l.settings:subcat:id, l.settings:sub_categories2 )" />
    <mvt:assign name="l.subcat2_count" value="miva_array_elements( l.settings:sub_categories2 )" />
    <mvt:if expr="l.subcat2_count GT 0">
    <mvt:foreach iterator="subcat2" array="sub_categories2">
    <section>
    <p></p>
    <ul class="c-form-list o-layout o-layout--wide">
    <li class="c-form-list__item o-layout__item u-width-10--m">
    <a name="&mvte:subcat2:code;"></a>
    <h3 style="margin-top:30px;"><strong>&mvte:subcat2:name;</strong></h3></li>
    <li class="c-form-list__item o-layout__item u-width-2--m">
    <h3> <a href="/&mvt:category:code;.html#top"><span class="u-font-small u-icon-chevron-up"></span>
    <strong class="u-color-red">Back to top</strong></a></h3></li>
    </ul>
    </section>
    
    <mvt:comment>tweaked with Ted's code</mvt:comment>
    
    <mvt:assign name="l.settings:myProducts" value="0" />
    <mvt:do name="l.doit" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:subcat2:id, g.Offset, l.settings:null, g.NextOffset, l.settings:myProducts )" />
    
    <section class="o-layout o-layout--row--l o-layout--wide">
    <div class="o-layout__item u-width-3--l">
    <mvt:if expr="l.settings:category:code EQ 'glazed-pearl-kitchen-cabinets' OR l.settings:category:code EQ 'chocolate-merlot-kitchen-cabinets' OR l.settings:category:code EQ 'cinnamon-spice-kitchen-cabinets' OR l.settings:category:code EQ 'sicilian-slate-kitchen-cabinets' OR l.settings:category:code EQ 'caspian-shaker-kitchen-cabinets' OR l.settings:category:code EQ 'WhiteSH-rta-kitchen-cabinets' OR l.settings:category:code EQ 'antique-white-painted-shaker-kitchen-cabinets' OR l.settings:category:code EQ 'Feather-kitchen-cabinets'">
    <mvt:else>
    <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(l.settings:subcat2:id, l.settings:subcat2:title_image)" />
    <img src="&mvt:subcat2:title_image:image;" alt="&mvte:subcat2:name;">
    </mvt:if>
    </div>
    <div class="o-layout__item u-width-9--l">
    
    <!-- placed outside product loop -->
    <mvt:assign name="l.settings:img:width" value="160"/>
    <mvt:assign name="l.settings:img:height" value="160"/>
    
    <mvt:foreach iterator="product" array="myProducts">
    <mvt:assign name="l.uri:store_id" value="g.Store:id" />
    <mvt:assign name="l.uri:screen" value="''" />
    <mvt:assign name="l.uri:page_id" value="0" />
    <mvt:assign name="l.uri:cat_id" value="0" />
    <mvt:assign name="l.uri:product_id" value="l.settings:product:id" />
    <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
    
    <section>
    <form class="o-layout__item u-width-12 inline-labeling ctgy-add-form" data-hook="purchase" action="&mvte:urls:BASK:auto;" method="post" name="add">
    <input type="hidden" name="Action" value="ADPR" />
    <input type="hidden" name="Product_Code" value="&mvte:product:code;" />
    <ul class="c-form-list o-layout o-layout--wide">
    <li class="c-form-list__item o-layout__item u-width-2--m">
    
    <!-- placed within the product loop -->
    <mvt:do file="g.Module_Library_DB" name="l.settings:sub_category:product:image_count" value="ProductImageDataList_Load_Product(l.setting s:product:id, l.settings:product:images)" />
    <mvt:foreach iterator="image" array="product:images">
    <mvt:if expr="l.settings:image:imagetype:code EQ 'main'">
    <mvt:assign name="l.settings:product:main_image" value="l.settings:image" />
    <mvt:foreachstop/>
    </mvt:if>
    </mvt:foreach>
    
    <mvt:do file="g.Module_Library_DB" name="l.result" value="GeneratedImage_FindOrInsert_Image_Dimension s( l.settings:product:main_image:image, l.settings:img:width, l.settings:img:height, l.settings:product:main_image:generated )" />
    <mvt:assign name="l.settings:image:mainthumb" value="l.settings:product:main_image:generated:ima ge" />
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, 'index', l.settings:product:index)" />
    <mvt:if expr="l.settings:product:index EQ 'yes'">
    
    <a data-mm-linktype="product-list-link" href="&mvt:canonical_uri:uri;">
    
    <mvt:if expr="l.settings:image:mainthumb">
    <img src="&mvte:image:mainthumb;" alt="&mvte:product:name;" />
    <mvt:else>
    <img src="graphics/00000001/1/image-coming-soon_160x160.png" alt="&mvte:product:name;" />
    </mvt:if>
    </a>
    <mvt:else>
    <mvt:if expr="l.settings:image:mainthumb">
    <img src="&mvte:image:mainthumb;" alt="&mvte:product:name;" />
    <mvt:else>
    <img src="graphics/00000001/1/image-coming-soon_160x160.png" alt="&mvte:product:name;" />
    </mvt:if>
    </mvt:if>
    </li>
    <li class="c-form-list__item o-layout__item u-width-4--m">
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, 'index', l.settings:product:index)" />
    <mvt:if expr="l.settings:product:index EQ 'yes'">
    
    <a href="&mvt:canonical_uri:uri;"><span>&mvt:product: name;</span></a>
    <mvt:else>
    <span>&mvt:product:name;</span>
    </mvt:if>
    <mvt:comment>
    <mvt:if expr="NOT ISNULL l.settings:product:descrip">
    <br>&mvt:product:descrip;
    </mvt:if>
    </mvt:comment>
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, 'notes', l.settings:product:notes)" />
    <mvt:if expr="NOT ISNULL l.settings:product:notes">
    <br><div class="custom-field" id="customfields-notes"><span class="bold">Notes:</span> &mvt:product:notes;</div>
    </mvt:if>
    </li>
    <li class="c-form-list__item o-layout__item u-width-2--m"> <span>$<mvt:eval expr="l.settings:product:price ROUND 2" /></span></li>
    <li class="c-form-list__item o-layout__item u-width-1--m"><span>
    <input class="form-control form-control-sm col-sm-4 text-center float-right cart-quantity ctgyQuantity" autocomplete="off" style="margin:0 auto" type="tel" min="0" name="Quantity" value="1">
    </span></li>
    <li class="c-form-list__item o-layout__item u-width-3--m">
    <input type="submit" value="Add to Cart" class="ctgyCart c-button c-button--full c-button--large c-control-group__button u-bg-primary u-color-yellow u-text-bold u-font-small u-text-uppercase">
    </li>
    </ul>
    </form>
    <hr class="c-keyline">
    </section>
    </mvt:foreach>
    
    </div>
    </section>
    </mvt:foreach>
    
    <mvt:assign name="l.settings:sub_categories2" value=" " />
    </mvt:if>
    </mvt:foreach>
    </mvt:if>

    Thoughts?
    TIA - Leslie
    Last edited by lesliekirk; 01-19-22, 06:39 AM.
    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

    #2
    Some times I hate when I stump the band...
    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


      #3
      I think that your problem is here:

      Code:
      <mvt:assign name="l.settings:sub_categories2" value=" " />
      Presuming this is intended to clear the array values, it doesn't seem to work. What you're getting instead is that existing array elements are overwritten with the new values, but only to the extent that the new array element count meets or exceeds the existing element count. You need to either delete or clear all values and element counts from the array before running the next sub_sub_category's loop.

      Try this in its place:

      Code:
      <mvt:assign name="g.return_value" value="miva_array_delete( l.settings:sub_categories2, 1, l.subcat2_count)" />
      
      ​​​​​​​

      Comment


        #4
        Thanks Leanne. Nick sent me something to try which might be a complete cleaner recoding of this. If it works as I need it to, I'll share it. But your fix seems so simple I may try it first
        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


          #5
          Originally posted by Leanne View Post
          I think that your problem is here:

          Code:
          <mvt:assign name="l.settings:sub_categories2" value=" " />
          Presuming this is intended to clear the array values, it doesn't seem to work. What you're getting instead is that existing array elements are overwritten with the new values, but only to the extent that the new array element count meets or exceeds the existing element count. You need to either delete or clear all values and element counts from the array before running the next sub_sub_category's loop.

          Try this in its place:

          Code:
          <mvt:assign name="g.return_value" value="miva_array_delete( l.settings:sub_categories2, 1, l.subcat2_count)" />
          Hey Leanne, consider yourself hugged. I am just too tired (very long story) to try the code Nick sent so I jumped right to your suggestion and it does exactly what I need. Thank you so much for simple tweak. I appreciated it sooooooo very much - Leslie
          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


            #6
            Yay, I love hugs! You are very welcome, and sorry things are hard for you right now.

            Comment

            Working...
            X