Hi,
Here is my folder structure:
Top Level
Sub Level
Sub Sub Level
Sub Level
Top Level
Sub Level
Sub Sub Level
Sub Sub Level
Sub Sub Level
Sub Sub Sub Level
Sub Sub Sub Level
Sub Level
So currently i can grab the parent ID for ’Top Level’ with the following code:
$id = $modx->documentIdentifier;
$pid = $modx->getParent($id,1,"id");
while ($pid['id'] != 0) {
$id = $pid['id'];
$pid = $modx->getParent($id,1,"id");
}
And it will be true for all sub levels under.
How do i grab the ’Sub Level’ id for all levels under ? What about ’Sub Sub Level’ ?
Any help will be greatly appreciated !
Aleks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
First better use the
UltimateParent snippet to get the parent ID, thoroughly tested and 2.0beta is even bundled with MODx
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
How can use the UltimateParent within another snippet?
[[UltimateParent? &id=`45` &top=`6`]]
As far as the getChild, i actually need the opposite

get the parent .. I think UltimateParent should work for me, just need to figure out how to call it within another snippet.
Thanks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
Oops sorry I misread your question (previous post edited) !
The current limitations of the parser force you to call it cached in an uncached snippet, for example...
[!Ditto? &parents=`[[UltimateParent? &id=`45` &top=`6`]]`!]
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
This is the full code that i use now:
<?php
$id = $modx->documentIdentifier;
$pid = $modx->getParent($id,1,"id");
while ($pid['id'] != 0) {
$id = $pid['id'];
$pid = $modx->getParent($id,1,"id");
}
switch ($id) {
case "55" : $zoneID = "{{contest_winners}}"; break; //contests
default: $zoneID = "[[BLOGS_right]]"; break;
}
echo $zoneID;
?>
so for all documents inside id 55 i get {{contest_winners}} chunk, for all others, some other snippet.
this is there i need the UltimateParent to give me SubParents under id 55

seems easy but i’m totally lost.
Thank you
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
Thanks for sharing, this could be handy
If I understood what you want to do correcty, this can also be achieved with
PHx :
[tt][+phx:if=`[[UltimateParent? &id=`[*id]` &topLevel=`1`]] `:is=`55`:then=`{{contest_winners}}`:else=`whatever you need here`+][/tt]
I used this kind of logic recently, works like a charm.
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
nice .. i’ll try now
here is a modified version that works for all levels:
<?php
$id = $modx->documentIdentifier;
$pid = $modx->getParent($id,1,"id");
while ($pid['id'] != 0) {
$id = $pid['id'];
$pid = $modx->getParent($id,1,"id");
}
$top = $id;
$cid = $modx->documentIdentifier;
$mid = $modx->getParent($cid,1,'id');
while ($mid['id'] != $top && $mid['id'] != 0) {
$cid = $mid['id'];
$mid = $modx->getParent($cid,1,'id');
}
switch ($id) {
case "55" : $zoneID = "{{contest_winners}}"; break; //contests
default: $zoneID = "[[BLOGS_right]]"; break;
}
switch ($cid) {
case "68" : $zoneID = "video pages"; break; //contests
default: $zoneID = "[[BLOGS_right]]"; break;
}
echo $zoneID;
?>
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
would you know how to put several if statements in it ?
just create extra calls ?
[+phx:if=`[[UltimateParent? &id=`[*id*]` &topLevel=`1`]] `:is=`55`:then=`{{contest_winners}}`:else=`whatever you need here`+]
[+phx:if=`[[UltimateParent? &id=`[*id*]` &topLevel=`1`]] `:is=`56`:then=`{{contest_winners}}`:else=`whatever you need here`+]
Thanks !
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
yo ... the PHx breaks the pagination on Ditto calls ...
took me a while to figure out where my pages went
Aleks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
Quote from: bakalek at Jun 01, 2007, 03:40 PMyo ... the PHx breaks the pagination on Ditto calls ... took me a while to figure out where my pages went 
Had the same problem, and took a bit of time too figuring this out
Quote from: bakalek at Jun 01, 2007, 01:22 PMwould you know how to put several if statements in it ? just create extra calls ?
No need, just use the [tt]or[/tt] operator (see
the wiki about this)
[+phx:if=`[[UltimateParent? &id=`[*id*]` &topLevel=`1`]] `:is=`55`:or:is=`56`:then=`{{contest_winners}}`:else=`whatever you need here`+]
Nice uh ?
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id