Announcement

Collapse
No announcement yet.

Need the correct link token

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

    Need the correct link token

    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.
    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>
    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.

    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>
    Suggestions are welcome, please.
    Last edited by lesliekirk; 08-26-22, 05:46 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
    Hey Leslie,
    Try: &mvte:subcat:link; for the link. What are you trying to accomplish here? Do you want to display all of the subcategories contained within the parent category of the category you're on?

    Comment


      #3
      Originally posted by RTHOMASDESIGN View Post
      Hey Leslie,
      Try: &mvte:subcat:link; for the link. What are you trying to accomplish here? Do you want to display all of the subcategories contained within the parent category of the category you're on?
      I am trying to display the subcategories of a specific parent category. The mvt:assign would have the actual category code in it.

      Code:
      <mvt:assign name="g.category_code" value="'category_code_here'" />
      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


        #4
        Anyway, if that's the case, then this should get you started:
        <mvt:if expr="l.settings:subcategories GT 0"><mvt:else>
        <mvt:foreach array="cattree_categories" iterator="cattree_category">
        <mvt:if expr="l.settings:cattree_category:parent_id EQ l.settings:category:parent_id">
        <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcats, l.settings:cattree_category, -1)" />
        </mvt:if>
        </mvt:foreach>
        <mvt:foreach iterator="sub_category_top" array="subcats">
        <!-- your subcategory template code here -->
        </mvt:foreach>

        Please note that this will only generate subcategories, for categories that do not contain subcategories (remove the initial if statement if you always want to generate).
        -Ryan

        Comment


          #5
          If the link still isn't working, try this:
          <mvt:assign name="g.category_code" value="'your category code'" />
          <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">

          <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code(l.settings:subcat:code, l.settings:product_list_category)" />
          <mvt:assign name="l.uri:store_id" value="g.Store:id" />
          <mvt:assign name="l.uri:cat_id" value="l.settings:product_list_category:id" />
          <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical(l.uri, l.settings:canonical_uri)" />

          <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:canonical_uri:uri;"><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:canonical_uri:uri;" 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>

          Comment


            #6
            Thanks Ryan,

            I've almost got it. Just a small tweak for a custom field and it should be done. Here's what I used

            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; margin-left:0;">
            <mvt:foreach iterator="subcategory" array="subcategories">
            <div class="o-layout__item x-product-list__item">
            <figure class="x-product-list__figure">
            <picture class="x-product-list__picture container">
            
            <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 class="t-lazy-load-image" src="graphics/00000001/1/specials-icon.png" width="75" height="75" alt="Special Pricing"></span>
            </mvt:if>
            <a class="u-block u-color-black x-product-list__link" href="&mvte:subcategory:link;">
            
            <img class="x-product-list__image t-lazy-load-image lazyload image" src="&mvte:subcategory:image;" alt="&mvte:subcategory:name; Ready to Assemble Kitchen Cabinets" loading="lazy"></a>
            <mvt:item name="customfields" param="Read_Category_Code( l.settings:subcat:code, 'hp_short_desc', l.settings:hp_short_desc )" />
            <div class="overlay"><a href="&mvte:subcategory:link;">&mvt:hp_short_desc; </a></div>
            </picture>
            <a class="u-block u-color-black x-product-list__link" href="&mvte:subcategory:link;" title="&mvte:subcategory:name;"> <figcaption class="x-product-list__figure-caption">
            
            <span class="x-product-list__name u-color-oxide">&mvte:subcategory:name;</span>
            </figcaption>
            </a></figure>
            </div>
            </mvt:foreach>
            </section>
            I found my issue just by posting it here. Now to fix it.

            Thanks again!
            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

            Working...
            X