Announcement

Collapse
No announcement yet.

Toolkit randomcat function

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

    Toolkit randomcat function

    Is there a native replacement for the Toolkit randomcat function?
    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
    There's nothing that does it with one line of code. But the template language can read products and make random selections, so it's possible to do it with a "paragraph" of template code.
    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


      #3
      Originally posted by Kent Multer View Post
      There's nothing that does it with one line of code. But the template language can read products and make random selections, so it's possible to do it with a "paragraph" of template code.
      Thanks - I wonder if it will ever be a Sort Method selection? I think I may have asked for it years ago, guess it's time to beg for it again. I know of a number of store owners who have asked about it.

      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
        its a rather short paragraph

        Code:
        <mvt:do name="l.settings:category_count" file="g.Module_Library_DB" value="Runtime_CategoryList_Load_All( l.settings:all_categories )" />
        <mvt:assign name="g.category_count" value="miva_array_max(l.settings:all_categories)" />
        <mvt:assign name="g.category_index" value="random(g.category_count)" />
        
        <mvt:comment> ### Debug ### </mvt:comment>
        all index: &mvt:global:category_index;<br>
        
        specific index:<mvt:eval expr="l.settings:all_categories[g.category_index]:id" /><br>
        
        <mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_ID(l.settings:all_categories[g.category_index]:id, l.settings:random:category)" />
        
        <mvt:comment> ### Debug ### </mvt:comment>
        &mvt:random:category:name;<br>
        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
          Bruce: I don't think that's what randomcat does, according to the documentation in the Miva app store: https://apps.miva.com/emporium-plus-tool-kit.html

          Leslie: I'm curious why your clients think that a random product order would be useful. I've always figured that randomcat was just for smaller things, such as a "You may also like ..." display at the bottom of a product page.
          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


            #6
            After reading the description from the UTILS TK page I am fairly sure the "randomcat" function is partially a confusing function name because it deals with the category product listing and is able to randomize the product selection in the targeted category. After glancing at Bruce's snippet, I think the logic is applicable. It's simply finding the range of indexes the array holds and randomly chooses. The only piece of code that may be missing is a method to prevent a repeat index chosen.

            Scott
            Last edited by ids; 11-21-21, 11:54 PM.
            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


              #7
              Originally posted by Kent Multer View Post
              Bruce: I don't think that's what randomcat does, according to the documentation in the Miva app store: https://apps.miva.com/emporium-plus-tool-kit.html

              Leslie: I'm curious why your clients think that a random product order would be useful. I've always figured that randomcat was just for smaller things, such as a "You may also like ..." display at the bottom of a product page.
              For places like the home page where you want to display 4 products from a category but not the same 4 products each time you visit the page. Not every layout is a slider so being able to randomize the display keeps it fresh.
              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


                #8
                Originally posted by Bruce - PhosphorMedia View Post
                its a rather short paragraph

                Code:
                <mvt:do name="l.settings:category_count" file="g.Module_Library_DB" value="Runtime_CategoryList_Load_All( l.settings:all_categories )" />
                <mvt:assign name="g.category_count" value="miva_array_max(l.settings:all_categories)" />
                <mvt:assign name="g.category_index" value="random(g.category_count)" />
                
                <mvt:comment> ### Debug ### </mvt:comment>
                all index: &mvt:global:category_index;<br>
                
                specific index:<mvt:eval expr="l.settings:all_categories[g.category_index]:id" /><br>
                
                <mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_ID(l.settings:all_categories[g.category_index]:id, l.settings:random:category)" />
                
                <mvt:comment> ### Debug ### </mvt:comment>
                &mvt:random:category:name;<br>
                Where are the product codes? The randomcat function randomizes products from a specific category.
                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


                  #9
                  Originally posted by Kent Multer View Post
                  Bruce: I don't think that's what randomcat does, according to the documentation in the Miva app store: https://apps.miva.com/emporium-plus-tool-kit.html
                  who reads documentation :)
                  Last edited by Bruce - PhosphorMedia; 11-20-21, 07:26 PM.
                  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 ids View Post
                    The only piece of code that may be missing is a method to have a repeat index chosen.

                    Scott
                    true, but if the array is at least 10 or so items deep, chances are you don't really need it in practical terms...otherwise, you have to do something like save the initial array in a basket field, load the initial array from there, and once a cat is displayed, remove that item from the arrary and stuff it back into the basket field.
                    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


                      #11
                      Originally posted by lesliekirk View Post

                      Where are the product codes? The randomcat function randomizes products from a specific category.
                      oh, then i read the request wrong. if you want x random products from a specific cat, you can still use the basic concept. i can post code for that specific function...but will have to wait until monday. its fly fishing day tomorrow.
                      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


                        #12
                        Not sure if this is relevant but in case it is useful Matt Zimmerman answered a question for me a few years ago regarding randomizing products in a product listing and it works well.

                        https://www.miva.com/forums/forum/de...fnt#post691053

                        Comment


                          #13
                          Originally posted by habreu View Post
                          Not sure if this is relevant but in case it is useful Matt Zimmerman answered a question for me a few years ago regarding randomizing products in a product listing and it works well.

                          https://www.miva.com/forums/forum/de...fnt#post691053
                          That looks like EXACTLY what I am looking for. I'll give it a show and let you know if it "works for me". Thanks!
                          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


                            #14
                            FYI - it WAS/IS exactly what I needed. Thank you!
                            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


                              #15
                              Originally posted by lesliekirk View Post

                              That looks like EXACTLY what I am looking for. I'll give it a show and let you know if it "works for me". Thanks!
                              I'll go to the linked post but the problem I have encountered is that it only randomizes the number of products displayed. For example, if Number of Products is set to 4, it only randomizes the same 4 products even though Products To Display is set to All Products.

                              I am trying to use the function in a Product Listing Theme Component.
                              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