Hi,
The following snippet allow you to display random text/images inside a document, useful for quotes, etc.
I need to vary some column content for a homepage and this content needs to be searchable - which the RandomQuote snippet cannot effectively do as it would appear outside of the containing document in a blank template.
The code required for RandomQuote seems fairly straightforward assuming you know your php and modx-isms which I’m currently noobing.
I just wondered if some kind soul could help me out here with some code for a snippet that can cycle between a few specified chunks, eg:
{{chunk1}} {{chunkII}} {{chunkIII}}
I’m sure this would be a useful snippet for many other souls and t’is the season to be jolly n all that
Thanks.
// RandomQuote
// Snippet to produce by sottwell.
// Posted by web_designer.
// Dated 25th Sepember 2006.
$resourceparent = $quoteid; // the folder that contains quote documents
$output = ''; // initialise the quote variable
$resource = $modx->getActiveChildren($resourceparent,'createdon', 'DESC', $fields='content');
$limit=count($resource);
if($limit<1) {
$output .= "No entries found.<br />";
return $output;
}
$random = (rand(1, $limit) - 1);
$output .= $resource[$random]['content']; // get a random quote
return $output;