I’m tring to output a menu with get resources but because the menu needs filtering I can’t use Wayfinder.
In Evo I would use Ditto and Wayfinder to do what I need. I would like to use getResources in Revo if possible but getResource returns a string not an array.
Is it possible to add a this as a setting to getResources?
I’d like that too -- returning an array of resources.
In the meantime, you might be able to use getCollection() in your snippet by calling
$modx->getChildIds() for each parent, merging the arrays with array_merge() and calling $modx->getCollection().
I think it would be this:
$c = array(
array('id:IN' => $eventsIds,
'published' => '1',
'deleted' => '0',
'hidemenut' => '0',
$resources = $modx->getCollection('modResource', $c);
Does this work with TVs as well, meaning can I get TV values with $modx->getCollection(’modResource’, $c);?
Yes, but it’s fairly complicated. Look at the getResources code.
Once you have the array of resources, you could always loop through it and get them with:
gR returns an array if not tpl is provided. Unfortunately that array is actually a string.
Would it be that hard to change it to actually return an array? Maybe there is a function that reverses a string array into an array.
I’ll take a look at it when I have some time.
I thought of another route. You could call getResources with runSnippet(). I’m working on an A to Z snippet that does that. If your Tpl chunk as some token at the beginning, you could then parse them into an array with explode(). If the Tpl chunk has placeholders for the TVs, I think getResources will replace them for you.
Was there a resolution to this? I ran up against the same getResources "array is really string" thing tonight when trying to use it to grab a few levels of resources. Otherwise, I guess I’ll just write something that uses getCollection and loops through more than enough levels to get what I need.
getCollection() would probably be faster (and usually easier, IMO), but it should also be easy to turn the getResources() return value into an array by putting ### at the very beginning of your Tpl chunk and doing this:
$results = getResources( ...);
$myArray = explode('###', $results);