I have a snippet that display all of the subcategories of a specific parent category. The problem I'm having is it uses &mvt:subcat:code;.html for the link. That creates exactly that a link with the subcategory code instead of the canonical URI.
Is there a way to use the existing code that displays subcategories but have it display the subcategories of a specific parent category? I tried changing the EQ l.settings:category:id to EQ the category code but it didn't work.
Suggestions are welcome, please.
Code:
<mvt:assign name="g.category_code" value="'category_code_here'" /> <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 )" /> <section class="o-layout u-grids-1 u-grids-2--m u-grids-3--l x-product-list" style="margin-top:16px; margin-left:0;"> <mvt:foreach iterator="subcat" array="sub_categories"> <div class="o-layout__item x-product-list__item"> <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattree.mvc'" name="l.success" value="CSSUI_CatTree_Load(l.settings:subcat:id, l.settings:subcat:tree_image)" /> <figure class="x-product-list__figure"> <picture class="x-product-list__picture container"> <a class="u-block u-color-black x-product-list__link" href="/&mvt:subcat:code;.html"><img class="x-product-list__image t-lazy-load-image lazyload image" src="&mvt:subcat:tree_image:image;" alt="&mvt:subcat:name;" width="510" height="402"></a> </picture> <a class="u-block u-color-black x-product-list__link" href="/&mvt:subcat:code;.html" title="&mvt:subcat:name;"> <figcaption class="x-product-list__figure-caption"> <span class="x-product-list__name u-color-oxide">&mvt:subcat:name;</span> </figcaption> </a></figure> </div> </mvt:foreach> </section>
Code:
<mvt:foreach array="cattree_categories" iterator="category_children"> <mvt:if expr="l.settings:category_children:parent_id EQ l.settings:category:id"> <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcategories, l.settings:category_children, -1)" /> </mvt:if> </mvt:foreach> <mvt:assign name="l.settings:subcategory_count" value="miva_array_elements(l.settings:subcategorie s)" /> <section class="o-layout u-grids-1 u-grids-2--m u-grids-3--l x-product-list" style="margin-top:16px;"> <mvt:foreach iterator="subcategory" array="subcategories"> <div class="o-layout__item u-text-center x-product-list__item"> <figure class="x-product-list__figure"> <!-- this needs to be changed <mvt:item name="customfields" param="Read_Category_Code( l.settings:subcategory:code, 'daisy', l.settings:daisy )" /> <mvt:if expr="l.settings:daisy"> <span class="x-product-label"><img src="graphics/00000001/LittleDaisy_transparent.png" alt="Discount Daisy" style="width:37px; height:37px;"></span> </mvt:if> <mvt:if expr="l.settings:subcategory:image"> <a href="&mvt:subcategory:link;"><img class="x-product-list__image t-lazy-load-image" src="&mvt:subcategory:image;" alt="&mvt:subcategory:name;" width="370" height="292"></a> </mvt:if> --> <h2 class="u-color-oxide" style="font-size:1.2rem; font-weight:bold;"><a href="&mvt:subcategory:link;">&mvte:subcategory:na me;</a></h2> </figure> </div> </mvt:foreach> </section>
Comment