Hey Ho
I'm totally new to Modx! Php is not my prefered language, too. Ok. I've got no idea of php...
Actually I was trying to get a multi context site running. many single pages (each one context) and one masterpage (another context) which should summarize sum pages of the other contexts. Multi Context was easy and seems to work, but getRessources wasn't showing my content.
content in each context is separated in folders.
- news
-- 2011
--- document
--- document
so getResources should start from 'news' and collect all data below.
In the same context this works well, from another context it's not working. I found that
$modx->getChildIds($parent, $depth);
is used wrong. It's only searching children in the current Context.
It's quite late now, so maybe not everything I'm saying makes sense.
I made a really
quick and dirty hack to this.
In getResources Snippet.php I removed lines 107-118 (chapter "multiple context support")
and added them (modified) on line 82. Ah yes, lines 82-85 are also moved. Now it looks like (starting line 82):
/* multiple context support */
if (!empty($context)) {
$context = explode(',',$context);
$contexts = array();
foreach ($context as $ctx) {
$contexts[] = $modx->quote($ctx);
foreach ($parents as $parent) {
$pchildren = $modx->getChildIds($parent, $depth, array("context"=>$ctx));
if (!empty($pchildren)) $children = array_merge($children, $pchildren);
}
}
$context = implode(',',$contexts);
unset($contexts,$ctx);
} else {
$context = $modx->quote($modx->context->get('key'));
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);
So there are two things I'd like to ask:
- Is there a way to file bugs for getResources?
- Can somebody with knowlegde of php AND modx please verify my bug,
and find a solution thats not dirty hacked like mine? (it's not really performant to have getChilds in foreach{foreach}... but i spent too much time to figure this out. php is not my world and modx is all new, so I'm not the guy to make this perfect.
Hope someone can reconstruct this bug and find a nice solution for it.
Kind regards,
martin