This hurts, because it must be teeth-gratingly simple to do, but my PHP understanding is minimal, let alone MODx. I’m trying to replicate a randomQuote generator that appears elsewhere on the forums for Evo. It uses a deprecated call (getActiveChildren) so needs tweaking for Revo.
I can find and loop through all resources I need:
$quotes = $modx->getCollection('modResource', array(
'parent' => $foldernumber,
'published' => 1 ));
foreach ($quotes as $quote) {
echo $quote->get('introtext')." + ";
}
I can shuffle them, but I can’t seem to work out how to call an individual row of the array correctly.
I thought it would be this:
echo $quotes[$somenumber]['introtext']
but it doesn’t seem to recognise the column heading ’introtext’ - I’m not referencing it correctly. I can’t find any examples that just want one item from a collection - or an example to output the contents of the whole array (ie what’s actually _in_ my $quotes variable), so I can’t easily see where I’m going wrong.
Help a noob out....