<![CDATA[ Problem getting Parent name - My Forums]]> https://forums.modx.com/thread/?thread=45612 <![CDATA[Re: Problem getting Parent name]]> https://forums.modx.com/thread/45612/problem-getting-parent-name#dis-post-263853 jusmeig Apr 04, 2011, 10:31 AM https://forums.modx.com/thread/45612/problem-getting-parent-name#dis-post-263853 <![CDATA[Problem getting Parent name]]> https://forums.modx.com/thread/45612/problem-getting-parent-name#dis-post-263852
I have a snippet that’s getting the name of the parent document (if there is a child). It worked like a charm till I tried to make it multilingual. Since this Parent snippet itself uses [*ID*] to get title, It seems I can’t use YAMS data call..

Original "ParentName" snippet code:

<?php
$parent = $modx->getParent($pageId,1,’pagetitle’);

$parentName = $parent[’pagetitle’];
$currentTitle = $modx->documentObject[’pagetitle’];

if ($parentName != ""){
return $parent[’pagetitle’];
}else{
return $currentTitle;
}
?>


and a snippet call:

[!ParentName? &pageId=`[*id*]`!]


I know I could use just [[YAMS? &get=`data` &from=`pagetitle` &docid=`[*id*]`]] to get multilingual title, but I really need to get this parent thing to work.
It would be so nice if someone could help me with this one..

Thanks in advance,
Roman



]]>
RTarvid Mar 30, 2011, 07:43 PM https://forums.modx.com/thread/45612/problem-getting-parent-name#dis-post-263852