That is exactly what I wanted!
Any chance this could be put into evo? We are concerned about our upgrade path in the future since we have about 60 sites on evo right now.
I actually got the plugin functional, but I don’t think the code is very efficient. For some reason I can’t get $modx->getParentIds or $modx->getParent to return anything except empty arrays, even if I hardcode a known resource ID into it.
So I ended up doing this, which I"m sure is inefficient but it works.
<?php
global $modx;
$id = $resource->get("id");
$parent = $resource->get(’parent’);
$depth = 1;
while($parent != 1) {
$r1 = $modx->getObject(’modResource’,$parent);
$parent = $r1->get(’parent’);
$depth++;
}
if ($depth > 3) {
$modx->event->output("The dwarves dug too deep and awoke something in the dark!");
}
?>
Quote from: pleth at Sep 07, 2010, 05:17 PM
I actually got the plugin functional, but I don’t think the code is very efficient. For some reason I can’t get $modx->getParentIds or $modx->getParent to return anything except empty arrays, even if I hardcode a known resource ID into it.
So I ended up doing this, which I"m sure is inefficient but it works.
<?php
global $modx;
$id = $resource->get("id");
$parent = $resource->get(’parent’);
$depth = 1;
while($parent != 1) {
$r1 = $modx->getObject(’modResource’,$parent);
$parent = $r1->get(’parent’);
$depth++;
}
if ($depth > 3) {
$modx->event->output("The dwarves dug too deep and awoke something in the dark!");
}
?>
$modx->getParentIds() has always worked for me. Are you sure you spelled it right? It’s easy to do it as getParentIDs by mistake.