Toolkit replacement for quick (quicklists)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SidFeyDesigns
    Mighty Mivite








    • Jan 2012
    • 598

    #1

    Toolkit replacement for quick (quicklists)

    Is there a miva replacement function for the toolkit quick function?

    How can I call in certain image sizes and custom fields within this code?

    Here is the current toolkit code I'm using. This is on a non category page template.

    Code:
    <div class="row o-layout category-product-layout" style="margin: 0 0.5rem">
        <mvt:item name="toolkit" param="quick|pcount|ILYR11,BMVRR11,MDR11C,TCR,BR11,WYMM11W,11MRPSB,WR11,11IGPR,11MDRIG,11IBBR,11MDRI B,11MR,11PRMSB,ICV3x2,TEFTG,TEFTS,TEFTGP,TEFTSP25,TEFTGP50" />
        <mvt:foreach iterator="quicklist" array="quicklists">
            <mvt:item name="toolkit" param="customimage|small|l.all_settings:quicklist:id||205|205|" />
            <mvt:item name="toolkit" param="customimage|big|l.all_settings:quicklist:id |" />
            <mvt:item name="toolkit" param="custom|wholesale_name|l.all_settings:quicklist:id|wholesale_name" />
            <mvt:item name="toolkit" param="custom|wholesale_msrp|l.all_settings:quicklist:id|wholesale_msrp" />
            <a class="view-image o-layout__item category-product" href="https://&mvt:global:domain:name;&mvt:global:imageroot;&mvte:global:big;" data-custom="https://&mvt:global:domain:name;&mvt:global:imageroot;&mvte:global:big;" title="&mvte:global:wholesale_name;">
                <div class="place-holder">
                    <img class="lazyload" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" width="207" height="207" data-src="&mvt:global:imageroot;&mvte:global:small;" alt="&mvte:global:wholesale_name;" title="&mvte:global:wholesale_name;">
                    <noscript><img src="&mvt:global:imageroot;&mvte:global:small;" width="207" height="207" alt="&mvte:global:wholesale_name;" /></noscript>
                </div>
                <p>&mvte:global:wholesale_name;</p>
                <p class="bold">MSRP: &mvte:global:wholesale_msrp;<br><span class="red">Log In for Price</span></p>
            </a>
        </mvt:foreach>
    </div>
    Thanks in advance.
    Nick Harkins
    www.loveisarose.com
  • ids
    Developer Partner








    • Mar 2006
    • 2171

    #2
    I think you can probably replicate with the SplitString function.

    Here's an example for usage:

    https://docs.miva.com/code-samples/for-each-continue

    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    Comment

    • Kent Multer
      Mega Mivite









      • Mar 2006
      • 3251

      #3
      For turning a comma-separated list into an array, there's an easier way.
      Code:
      <mvt:assign name="l.settings:MyArray" value="miva_array_serialize(l.settings:MyString)" />
      Then inside the loop, you can use mvt:do to call a library function such as Product_Load_Code for each product
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment

      • SidFeyDesigns
        Mighty Mivite








        • Jan 2012
        • 598

        #4
        Thank you for those ideas ids and Kent Multer .

        I ended up using Kent's suggestion but both will work.

        You can replace Kent Multer 's suggestion :

        <mvt:assign name="l.settings:quick_list_array" value="miva_array_deserialize( g.quickitems )" />

        with the suggestion from ids :

        <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.quickitems, ',', l.settings:quick_list_array )" />

        Here's the code in case anyone needs it as a reference.

        Code:
        [COLOR=#c0392b]<mvt:comment> Enter your comma separated list of product codes below</mvt:comment>[/COLOR]
        <mvt:assign name="g.quickitems" value="'[COLOR=#c0392b]your_product_code1,your_product_code2,your_product_code3,your_product _code4[/COLOR]'" />
        
        <mvt:assign name="l.settings:quick_list_array" value="miva_array_deserialize( g.quickitems )" />
        <mvt:assign name="g.counter" value="0" />
        <mvt:foreach iterator="item" array="quick_list_array">
            <mvt:assign name="g.counter" value="g.counter + 1" />
            <mvt:do name="l.return" file="g.Module_Library_DB" value="Product_Load_Code( l.settings:quick_list_array[g.counter], l.settings:product )" />
            <mvt:do name="l.image_count" file="g.Module_Library_DB" value="ProductImageDataList_Load_Product( l.settings:product:id, l.settings:imagedata )" />
            <mvt:foreach iterator="data" array="imagedata">
        
        [COLOR=#c0392b]<mvt:comment>Check if main image type is present</mvt:comment>[/COLOR]
                <mvt:if expr="l.settings:data:imagetype:code EQ 'main'">
        
        [COLOR=#c0392b]<mvt:comment> Use the image dimensions you need below</mvt:comment>[/COLOR]
                    <mvt:assign name="l.constraints[1]:height" value="[COLOR=#c0392b]205[/COLOR]" />
                    <mvt:assign name="l.constraints[1]:width" value="[COLOR=#c0392b]205[/COLOR]" />
        
                    <mvt:assign name="l.imagetype_codes[1]" value="'main'" />
                    <mvt:assign name="l.constraints_count" value="miva_array_elements( l.constraints )" />
                    <mvt:assign name="l.imagetypecode_count" value="miva_array_elements( l.imagetype_codes )" />
                    <mvt:do file="g.Module_Library_DB" name="l.imagedata_count" value="ProductImageDataList_Load_Product_TypeCodes _Constrained( l.settings:product:id, l.imagetype_codes, l.imagetypecode_count, l.constraints, l.constraints_count, l.settings:productimagedatalist )" />
                    <a href="/&mvt:product:code;.html" title="&mvte:product:code;">
                        <img src="&mvt:productimagedatalist[1]:generatedimages[1]:image;" alt="&mvte:product:name;" title="&mvte:product:name;"><br>
                        &mvt:product:name;<br>
                        &mvt:product:price;<br>
                    </a>
        
        [COLOR=#c0392b]<mvt:comment>Stop The Loop. Important!</mvt:comment>[/COLOR]
                    <mvt:foreachstop/>
        
        [COLOR=#c0392b]<mvt:comment>No main image? Serve Place holder image</mvt:comment>[/COLOR]
                <mvt:else>
                    <a href="/&mvt:product:code;.html" title="&mvte:product:code;">
                        <img src="some/path/image_coming_soon.gif" alt="&mvte:product:name;" title="&mvte:product:name;"><br>
                        &mvt:product:name;<br>
                        &mvt:product:price;<br>
                    </a>
        
        [COLOR=#c0392b]            <mvt:comment>Stop The Loop. Important!</mvt:comment>[/COLOR]
                    <mvt:foreachstop/>
                </mvt:if>
            </mvt:foreach>
        </mvt:foreach>
        The values of the height and width constraints will be determined by the image size you are trying to load.

        In the case above, they were the images generated by the image machine for the CTGY product lists which is 205x205

        Any of the product related entities should work within the loop.

        &mvt:product:code;
        &mvt:product:name;
        &mvt:product:price;
        &mvt:product:descrip;
        &mvt:product:sku;
        etc.

        This code sample helped me find the specific image size generated by the image machine:

        https://docs.miva.com/code-samples/o...-product-image

        Thanks again for pointing me in the right direction guys!
        Last edited by SidFeyDesigns; 08-27-21, 02:36 PM. Reason: Added fallback if no main image type is present. Took out the code specific for our website. Added red comments to point out important code
        Nick Harkins
        www.loveisarose.com

        Comment

        • SidFeyDesigns
          Mighty Mivite








          • Jan 2012
          • 598

          #5
          (deleted repeated post)
          Last edited by SidFeyDesigns; 10-09-20, 01:39 PM.
          Nick Harkins
          www.loveisarose.com

          Comment

          • Kent Multer
            Mega Mivite









            • Mar 2006
            • 3251

            #6
            OOPS, sorry! I should have written miva_array_deserialize, not miva_array_serialize.
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment

            • SidFeyDesigns
              Mighty Mivite








              • Jan 2012
              • 598

              #7
              Originally posted by Kent Multer View Post
              OOPS, sorry! I should have written miva_array_deserialize, not miva_array_serialize.
              Thanks Kent Multer ! I have updated the post.
              Nick Harkins
              www.loveisarose.com

              Comment

              • lesliekirk
                Super Moderator











                • Aug 2008
                • 9289

                #8
                I stumbled upon this post while trying to find an issue to my own inability to get a product image to display within the sub-sub category listing



                I looked at the above coding and pulled out what looked like it would "work for me":
                Code:
                <mvt:do name="l.image_count" file="g.Module_Library_DB" value="ProductImageDataList_Load_Product( l.settings:product:id, l.settings:imagedata )" />
                <mvt:assign name="l.constraints[1]:height" value="75" />
                <mvt:assign name="l.constraints[1]:width" value="75" />
                <mvt:assign name="l.imagetype_codes[1]" value="'main'" />
                <mvt:assign name="l.constraints_count" value="miva_array_elements( l.constraints )" />
                <mvt:assign name="l.imagetypecode_count" value="miva_array_elements( l.imagetype_codes )" />
                <mvt:do file="g.Module_Library_DB" name="l.imagedata_count" value="ProductImageDataList_Load_Product_TypeCodes _Constrained( l.settings:product:id, l.imagetype_codes, l.imagetypecode_count, l.constraints, l.constraints_count, l.settings:productimagedatalist )" />
                <img src="&mvt:productimagedatalist[1]:generatedimages[1]:image;" width="75" height="75" alt="&mvte:global:product_name;" />

                It does pretty much exactly what I have (which I had found in the samples):

                Code:
                <mvt:assign name="l.constraints[1]:height" value="75" />
                <mvt:assign name="l.constraints[1]:width" value="75" />
                <mvt:assign name="l.imagetype_codes[1]" value="'main'" />
                
                <mvt:assign name="l.constraints_count" value="miva_array_elements( l.constraints )" />
                <mvt:assign name="l.imagetypecode_count" value="miva_array_elements( l.imagetype_codes )" />
                
                <mvt:do file="g.Module_Library_DB" name="l.imagedata_count" value="ProductImageDataList_Load_Product_TypeCodes _Constrained(l.settings:product:id, l.imagetype_codes, l.imagetypecode_count , l.constraints,l.constraints_count,l.settings:produ ctimagedatalist)" />
                
                <mvt:comment>
                | Check and see if the image exists, if not, Generate the file and return its path.
                </mvt:comment>
                
                <mvt:if expr="ISNULL l.settings:productimagedatalist[1]:generatedimages[1]:image">
                <mvt:do file="g.Module_Library_DB" name="l.ok" value="GeneratedImage_FindOrInsert_Image_Dimension s( l.settings:productimagedatalist[1]:image, l.constraints[1]:width, l.constraints[1]:height, l.settings:generatedimage )" />
                <a data-mm-linktype="product-list-link" href="<a href="/&mvt:product:code;.html"><img src="&mvt:generatedimage:image;" alt="&mvte:product:name;-generated" /></a>
                <mvt:else>
                <a data-mm-linktype="product-list-link" href="/&mvt:product:code;.html"><img src="&mvt:productimagedatalist[1]:generatedimages[1]:image;" alt="&mvte:product:name;-data" /></a>
                </mvt:if>

                The problem I'm having with either one of these is that it is pulling in an image when there isn't one to pull in. I'm not even sure where it's coming from. I'd just like to be able to display an "Image Coming Soon" default image if there isn't one to be found.





                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

                • SidFeyDesigns
                  Mighty Mivite








                  • Jan 2012
                  • 598

                  #9
                  lesliekirk I am actually not too sure.

                  When I use the token list on the page template with the above code, I noticed the imagedata count stops at 7 when there is supposed to be 20 products.

                  So I think there is definitely an issue with the above code although I can't seem to pinpoint why the count is stopping.

                  I also found this https://gist.github.com/steveosoule/...a02c0d1732ea6c

                  I feel somehow this could be worked in to give the ability to create a conditional if the image type of main is not present.

                  Currently I do not have the energy to figure it out though.

                  Maybe because its Friday haha.
                  Last edited by SidFeyDesigns; 08-27-21, 12:38 PM.
                  Nick Harkins
                  www.loveisarose.com

                  Comment

                  • SidFeyDesigns
                    Mighty Mivite








                    • Jan 2012
                    • 598

                    #10
                    lesliekirk I actually think I just figured it out.

                    Try this:

                    Code:
                    <mvt:do name="l.image_count" file="g.Module_Library_DB" value="ProductImageDataList_Load_Product( l.settings:product:id, l.settings:imagedata )" />
                    <mvt:foreach iterator="data" array="imagedata">
                        <mvt:if expr="l.settings:data:imagetype:code EQ 'main'">
                            <mvt:assign name="l.constraints[1]:height" value="75" />
                            <mvt:assign name="l.constraints[1]:width" value="75" />
                            <mvt:assign name="l.imagetype_codes[1]" value="'main'" />
                            <mvt:assign name="l.constraints_count" value="miva_array_elements( l.constraints )" />
                            <mvt:assign name="l.imagetypecode_count" value="miva_array_elements( l.imagetype_codes )" />
                            <mvt:do file="g.Module_Library_DB" name="l.imagedata_count" value="ProductImageDataList_Load_Product_TypeCodes_Constrained( l.settings:product:id, l.imagetype_codes, l.imagetypecode_count, l.constraints, l.constraints_count, l.settings:productimagedatalist )" />
                            <a data-mm-linktype="product-list-link" href="/&mvt:product:code;.html"><img src="&mvt:productimagedatalist[1]:generatedimages[1]:image;" alt="&mvte:product:name;" /></a>
                            ​​​​<mvt:foreachstop/>
                        <mvt:else>
                            <a data-mm-linktype="product-list-link" href="/&mvt:product:code;.html"><img src="some/path/image_coming_soon.gif" alt="&mvte:product:name;" /></a>
                            <mvt:foreachstop/>
                        </mvt:if>
                    </mvt:foreach>
                    It worked for me so I will update the post above to have a solution with a fallback if there is no main image type
                    Nick Harkins
                    www.loveisarose.com

                    Comment

                    Working...
                    X