<![CDATA[ Display the parent's pagetitle - My Forums]]> https://forums.modx.com/thread/?thread=11074 <![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=3#dis-post-498733 ojchris May 27, 2014, 09:25 AM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=3#dis-post-498733 <![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=3#dis-post-498670
If, OTOH, the tag is in a Tpl chunk being used by something like getResources, it would be the plus sign.

]]>
BobRay May 26, 2014, 11:30 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=3#dis-post-498670
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-498650
[[!MY_GetPageTitle? &id=`[[+parent]]`]]


should now read

[[!MY_GetPageTitle? &id=`[[*parent]]`]]


Notice the asterisks and plus character preceeding parent]]>
ojchris May 26, 2014, 04:03 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-498650
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-465803 Quote from: sunwukung at Nov 17, 2010, 11:02 AM
Here's a variation on mrhaw's using revo:

$parentID = $modx->resource->get('parent');
$document = $modx->getObject('modResource',array(
    'id' => $parentID,
   ));
return $document->get('pagetitle');

Works, thanks man!]]>
ilja-web May 09, 2013, 07:01 AM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-465803
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-454104 ]]> BobRay Feb 06, 2013, 05:03 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-454104 <![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-454048
Snippet Code

<?php
/**
 * MY_GetPageTitle
 *
 * DESCRIPTION
 *
 * This snippet returns the title of a page matching an id
 *
 * USAGE:
 *
 * [[!MY_GetPageTitle? &id=`[[+parent]]`]]
 */

$page = $modx->getObject('modResource', $id);
if(!empty($page)) {
	return $page->get('pagetitle');
}
return '';


Template Code

[[!MY_GetPageTitle? &id=`[[+parent]]`]]]]>
simonbingham Feb 06, 2013, 08:41 AM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-454048
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63480 [[*parent:ne=`0`:then=`Parent page: <a href="[[~[[*parent]]~]]">[[getResourceField? &id=`[[*parent]]`]]</a>`:else=``]]

If parent exists it will display it, unless the parent is home page (id=0).]]>
encho Apr 02, 2011, 08:52 AM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63480
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63479 Quote from: lukemcd at Feb 19, 2011, 03:41 AM

Another option for Revo is to use the getResourceField extra...

You rock. Exactly what I needed; thank you!]]>
MrFussyfont Mar 25, 2011, 05:35 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63479
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63478 Quote from: sunwukung at Nov 17, 2010, 11:02 AM

Here’s a variation on mrhaw’s using revo:

$parentID = $modx->resource->get('parent');
$document = $modx->getObject('modResource',array(
    'id' => $parentID,
   ));
return $document->get('pagetitle');


Let me tweak that Revo version slightly:

<?php
$parentObj = $modx->resource->getOne('Parent');
return $parentObj->get('pagetitle');

]]>
BobRay Feb 18, 2011, 09:49 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63478
<![CDATA[Re: Display the parent's pagetitle]]> https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63477
[[getResourceField ? &id=`[[*parent]]` &field=`pagetitle`]]


And if you want to display the current page’s title if there is no parent use;

[[getResourceField:ifempty=`[[*pagetitle]]` ? &id=`[[*parent]]` &field=`pagetitle`]]
]]>
lukemcd Feb 18, 2011, 09:41 PM https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-63477