Hello
I was wondering whether there is a snippet that would allow me to randomly show a quote on a page.
Preferably, I’d like to have all the quotes in one chunk like:
quote 1
quote 2
quote 3
quote 4
etc.
I think this is the easiest way to maintain it.
thank you in advance for pointing me to the right direction.
I know there’s a random quotes snippet on the forums, but I can’t find it.
If you separate the quotes with a delimiter ( e.g. #) all you need is something like this:
$quotes = $modx->getChunk('quotes);
$quoteArray = explode('#',$quotes);
return (array_rand($quoteArray));
Thanks - really appreciate it
found a snippet that keeps the quotes in an external file that offers some features on how often to change the quote and stuff like that - basically nice but I still rather have the quotes in modx
Sorry, typo on my part---I left out a quote mark:
$quotes = $modx->getChunk('quotes);should be
$quotes = $modx->getChunk('quotes');
Sorry, I forgot that array_rand() returns a key to the associative array.
Glad you got it sorted.