I’ve been searching and searching, but can’t find the solution, or I’m not looking in the right place or using the right keywords.
Is it possible to have a custom module of say 50 items, just output 1 randomly? I’m not talking about the order. On page load, go to [module] and randomly display one item (which happens to be an image if that helps).
Any assistance would be greatly appreciated.
Thanks in advance.
The random
parameter will work in this case along with a limit
of 1
.
For example:
{% component source: "Portfolio", layout: "List", random: "true", limit: "1", type: "module" %}
Documentation for more info:
Component Type: Module (Custom Modules)
NOTE:
When testing this on your site and refreshing the page, the random result is stored in a Liquid cache for around 10 seconds. So refreshing the page within 10 sec will return the same item (this is for performance reasons).
Great, thank you. That is what I started with, but didn’t know about the 10-second refresh. So when testing, it was stuck on the same record every time, so I thought I was doing something wrong.
Thanks again!