I’m trying to get all documents in all contexts, I’ve succeeded at getting resources out of multiple contexts, but it doesn’t recurse through parents. My call looks like:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&context=`context1,context2`
&depth=`10`
&limit=`5`
&showUnpublished=`1`
&showHidden=`1`
&parents=`0`
&sortby=`editedon`
&tpl=`archiveListItem`
]]
it grabs all resources w/o getting any of their children. I believe I have sufficiently cleared my site cache, I also took a look at the raw array, it didn’t show me anything different. If I manually put in &parents=`0,3` it does get the children of resource #3 but it doesn’t get it’s children. I’ve looked around at other posts and didn’t see a similar problem. Am I missing something?
UPDATE: I’m now wondering if I just didn’t set up my context properly. Would this make any sense?
UPDATE #2: So I must have coppied over my core.config.php for the new context, that was causing some other problems, but that was worked out and now we’re at the same place we were. I have thoroughly tested out the problem and it’s obvious that getResource is only able to recurse through parents within the parent context of the snippet.
Example:
Context#1 lists all resources from Context#1 & Context#2 on the first level only, it also recurses though all resources within Context #1. Failing to recurse through Context#2.
Context#2 lists all resources from Context#1 & Context#2 on the first level only, it also recurses though all resources within Context #2. Failing to recurse through Context#1.
I’ve got some other work to do, but this sounds like a bug in getResource, I’ll be looking later.
UPDATE #3: The error exists some where in here I believe. Don’t know what else to say...?
$children = array();
foreach ($parents as $parent) {
$pchildren = $modx->getChildIds($parent, $depth);
if (!empty($pchildren)) $children = array_merge($children, $pchildren);
}
if (!empty($children)) $parents = array_merge($parents, $children);
Has nobody ran into this before?
[tt]$modx->getChildIds($parent, $depth)[/tt] w/ [tt]$parent=0[/tt] only gets children in that context, that’s why I’m not getting fully recursive results.