Hi, how do I include a parent name within my ditto template?
I have a group, I’m using ditto to list pages from said group, and I’d like to show the parent name along with the parent link using by using:
<a href="[~[+parent+]~]">? required parent name?</a>
Thanks,
Quote from: SandersDesign at Nov 29, 2009, 09:17 PM
Hi, how do I include a parent name within my ditto template?
I have a group, I’m using ditto to list pages from said group, and I’d like to show the parent name along with the parent link.
Thanks,
I think this would do it (untested) as long as the parent is published:
<a href="[~[+parent+]~]">[[ParentName? &pageId=`[+id+]`]]</a>
ParentName Snippet:
<?php
$parent = $modx->getParent($pageId,1,'pagetitle');
return $parent['pagetitle'];
?>
thanks BobRay
Quote from: SandersDesign at Nov 29, 2009, 09:48 PM
thanks BobRay 
Don’t thank me until it works.
Just a question related to this..
What if I waant to display /firstparent/secondparent/
(where your solution solved displayed /secondparent/)
I can’t seem to understand how to also display /firstparent/
Ultimately I would like to end up with <a href="[~[+parent+]~]">[[ParentName? &pageId=`[+id+]`]]</a>/<a href="[~[+parent+]~]">[[ParentName? &pageId=`[+id+]`]]</a>/
(So I can click either of the parents links)
OR you could install a PHx modifier
<a href="[~[+parent+]~]">[+phx:parent=`pagetitle`+]</a>
Name snippet "phx:parent"
<?php
$field = (strlen($options)>0) ? $options : 'pagetitle';
$parent = $modx->getParent($output,1,$field);
return $parent[$field];
?>
@kjartan
http://modxcms.com/extras/package/?package=173
Nice @oori
I screwed up above
It has to be given an id:
[+phx:parent=`pagetitle`+]
LIKE THIS: [+id:parent=`pagetitle`+] or parent’s parent [+parent:parent=`pagetitle`+]