//
// Code from page 363 of MODX - The Official Guide - getObjectGraph()
//
// ObjectDemo is under the Home Page (1)
//
$output .= '<p><h2>Me and my Parent</h2></p>';
$id = $modx->resource->get('id');
$gresource = $modx->getObjectGraph('modResource',array('Parent' => array()), $id);
$output .= '<p><h3>Me: ' . $gresource->get('pagetitle') . '</h3></p>';
try {
$pptitle = $gresource->Parent->get('pagetitle');
} catch (Exception $e) {
$pptitle = '';
}
$output .= ' - pptitle is: ' . $pptitle . '
'; // shows ObjectDemo not Home Page.
if ($pptitle > '') {
$output .= ' <h3>My Parent: ' . $pptitle . '</h3>'; // shows ObjectDemo not Home Page.
}]
Don't understand what is wrong.
The code: $pptitle = $gresource->Parent->get('pagetitle'); fails to get the parent pagetitle.
Do I have something wrong here?
Thanks,
Bill Slaughter
Offhand, I don't see anything wrong with your code. The code in the book worked when I tested it, but that was a while ago. I'll try to find time to check it out.
What version of MODX are you using?
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
Using version: 2.2.0-pl2.
I like the specs!
Thanks,
Bill Slaughter
Looks like a bug in xPDO. The equivalent code still works with user/Profile, but I get the same thing you do with resource/Parent. I've filed it as a bug.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html