-
☆ A M B ☆
- 24,524 Posts
This is an auto-generated support/comment thread for
UltimateParent.
Use this forum to post any comments about this addition or any questions you have regarding its use.
Brief Description:
Returnt the "ultimate" parent of the current document.
Hmm, this snippet didn’t work for me. The getParent returns the id in an array and when the while clause runs, it tried to put the id to the getParent call as an array and I get an parse error. So I did changes from $pid to $pid[’id’] what works for me:
$top = isset($top) ? $top : 0;
$id = isset($id) ? $id : $modx->documentIdentifier;
if($id==$top || $id==0) { return $id; }
$pid = $modx->getParent($id,1,'id');
if($pid['id'] == $top) { return $id; }
while ($pid['id'] != $top && $pid['id'] != "") {
$id = $pid['id'];
$pid = $modx->getParent($id,1,'id');
if($pid['id'] == $top) { return $id; }
}
return 0; // if all else fails
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
-
MODX Staff
- 10,725 Posts
Snippet updated to 1.2 with those changes doze. I noticed this when testing out a site a few weeks ago; not sure why this isn’t a problem for more people. ?? Anyway, problem resolved.
-
MODX Staff
- 10,725 Posts
My bad, forgot to copy the final corrected version into my text file before uploading. Problem has been corrected, but I kept the version at 1.2.
I also changed the example in the repository and the code comments.
I really wish you’d at least made it 1.2a, as the older 1.2 almost got into 0.9.5 beta 3, which would have been confusing!
Thanks for changing the example tho..
When I call UltimateParent with [!UltimateParent? &top=`2`!] apache gets a lot of load and then times out. Anyone else had any problems?
Apache version 1.3.33
PHP version 4.3.10
-
☆ A M B ☆
- 24,524 Posts
Snippets don’t like & I’ve had a lot of trouble with that when the RTE "helpfully" converts the & to &
The solution I use (if I must edit that page with the RTE) is to use the snippet configuration tab instead of arguments in the snippet call. You do it like this:
&variableName=Label;type(int, text, etc);default-value &nextVariableName=Label;type;default-value
The snippet will use the $variableName and $nextVariableName.
Or, you can put the snippet call in a chunk and put the chunk in the document.
Well.. I have the snippet call in a chunk, so that probably is not the problem. Tried calling just [!UltimateParent!] and that worked well, but not if I specify &top. I call WayFinder in the same chunk and that works well. Any ideas?