Is there a native replacement for the Toolkit randomcat function?
Announcement
Collapse
No announcement yet.
Toolkit randomcat function
Collapse
X
-
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
Tags: None
-
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
-
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.Originally posted by Kent Multer View PostThere'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.
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
-
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
-
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
-
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.
ScottLast 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
-
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.Originally posted by Kent Multer View PostBruce: 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.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
-
Where are the product codes? The randomcat function randomizes products from a specific category.Originally posted by Bruce - PhosphorMedia View Postits 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>
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
-
who reads documentation :)Originally posted by Kent Multer View PostBruce: 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.htmlLast 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
-
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.Originally posted by ids View PostThe only piece of code that may be missing is a method to have a repeat index chosen.
Scott
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
-
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.Originally posted by lesliekirk View Post
Where are the product codes? The randomcat function randomizes products from a specific category.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
-
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
-
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!Originally posted by habreu View PostNot 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#post691053Leslie 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
- 1 like
Comment
-
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
- 1 like
Comment
-
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.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 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
Comment