Announcement

Collapse
No announcement yet.

Toolkit randomcat function

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

  • lesliekirk
    replied
    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.

    Leave a comment:


  • lesliekirk
    replied
    FYI - it WAS/IS exactly what I needed. Thank you!

    Leave a comment:


  • lesliekirk
    replied
    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!

    Leave a comment:


  • habreu
    replied
    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

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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.

    Leave a comment:


  • lesliekirk
    replied
    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.

    Leave a comment:


  • lesliekirk
    replied
    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.

    Leave a comment:


  • ids
    replied
    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.

    Leave a comment:


  • Kent Multer
    replied
    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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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>

    Leave a comment:


  • lesliekirk
    replied
    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.

    Leave a comment:


  • Kent Multer
    replied
    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.

    Leave a comment:


  • lesliekirk
    started a topic Toolkit randomcat function

    Toolkit randomcat function

    Is there a native replacement for the Toolkit randomcat function?
Working...
X