Announcement

Collapse
No announcement yet.

Convert Toolkit Snippet to Display sub_categories for Specific Category

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

    Convert Toolkit Snippet to Display sub_categories for Specific Category

    I have a Toolkit Snippet that I would like to convert. It pulls in the specific sub_categories for a category assigned to it

    Code:
    <mvt:assign name="g.category_code" value="'category_code_here'" />
    <mvt:item name="toolkit" param="subcat|ccount|g.category_code" />
    <mvt:if expr="ccount GT 0">
            <mvt:foreach iterator="sub_category" array="sub_categories">
                      <div class="col-md-4 col-sm-4 col-xs-6">
          <div class="pbox image psmall">
            <div>
             <mvt:item name="toolkit" param="catimage|bigimage|l.all_settings:sub_category:code" />
    <mvt:if expr="bigimage">
    <a href="/&mvta:sub_category:code;.html"><img src="&mvte:global:bigimage;" class="img-responsive" alt="&mvt:sub_category:name;" title="&mvt:sub_category:name;"></a>
    <mvt:else>
    <a href="/&mvta:sub_category:code;.html"><img src="https://placehold.it/250x150&text=250x150+image" class="img-responsive" alt="Shop &mvte:sub_category:name; Now" title="Shop &mvt:sub_category:name; Now" /></a>
    
    </mvt:if>
              <p><strong><a href="/&mvta:sub_category:code;.html">&mvt:sub_category:name;</a></strong></p>
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
            </mvt:foreach>
    </mvt:if>

    ps ... I guess we should either create a forum or a GitHub dedicated to converting Toolkit Snippets.
    Last edited by lesliekirk; 11-25-19, 10:12 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: X | Facebook | Pinterest

    #2
    There is one:

    https://docs.miva.com/template-langu...ement-examples

    Look for "subcats"
    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
      Originally posted by Bruce - PhosphorMedia View Post
      That's a start - how do I pull in images? My continuing thoughts here is to build a repository of replacement code for all of the Toolkit snippets.
      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: X | Facebook | Pinterest

      Comment


        #4
        Which images? You can get the category title image with
        Code:
        <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(l.settings:category:id, l.settings:category:cat_title)" />
        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
          Okie dokie, once I get this crafted (and working) I will post the code.
          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: X | Facebook | Pinterest

          Comment


            #6
            I've got the subcats for a specific category but I'm still having issues with the images. I don't quite follow how to implement the mvt:do that Bruce provided. I've dug through other coding to see if I could find a pattern that would make sense. Here is what I have to pull in the subcats from the assigned category:

            Code:
               <mvt:assign name="g.category_code" value="'my-cat-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="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" /> 
             <mvt:foreach iterator="subcat" array="sub_categories">    
                 &mvt:subcat:name; <br>
             </mvt:foreach>
            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: X | Facebook | Pinterest

            Comment


              #7
              again, only if you have the image stored as the cat title image (which makes sense at least to me)

              Code:
              <mvt:assign name="g.category_code" value="'my-cat-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="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" /> 
              
              <mvt:foreach iterator="subcat" array="sub_categories">    
              
                 <mvt:do file="g.Module_Root $ '/modules/component/cmp-cssui-cattitle.mvc'" name="l.success" value="CSSUI_CatTitle_Load(l.settings:subcat:id, l.settings:subcat:title_image)" />
                 &mvt:subcat:name; <br>
                 <img src="&mvt:subcat:title_image;">
              
              </mvt:foreach>
              oh, and waiting for the second pot of coffee so...
              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


                #8
                This code is loading something into the image path so it comes out like this:

                Code:
                <img src="19,/images/Cafe_Latte_ Kitchen_Cabinets.jpg">
                Each image has a different number. I'm thinking that might be subcat:id? Then there seems to be a "phantom" image at the end of the list. I'll try to dig and see if it's what the number might belong to - it doesn't have any subcat name;

                Code:
                <img src="3561,">
                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: X | Facebook | Pinterest

                Comment


                  #9
                  told ya i was low on caffeine

                  &mvt:subcat:cat_title:image;
                  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


                    #10
                    Originally posted by Bruce - PhosphorMedia View Post
                    told ya i was low on caffeine

                    &mvt:subcat:cat_title:image;
                    Hmmm, maybe too much caffeine, that isn't displaying anything at all now.
                    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: X | Facebook | Pinterest

                    Comment


                      #11
                      sorry in your case
                      &mvt:subcat:title_image:image; (copied the original from code i was just working on.)
                      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

                      Working...
                      X