Nope, that didn’t work either. Now instead of Array it says nothing. Does it matter that the document I’m using the snippet belongs to a document group?
Well bang goes that theory! I tried using the snippet in a public document and still the same problem. I just don’t get what I’m doing wrong!
Well using your suggestion has suddenly started working. Could someone explain why when using the method in the documentation doesn’t work but using the above method does? I’d really like to understand the difference.
Many thanks!
snippet (parent_title)
<?php
// created by Badichan Dmitriy (c) badichan.com
$page = $modx->getObject('modResource', $input);
$id = $page->get('parent');
$parent_page = $modx->getObject('modResource', $id);
echo $parent_page->get('pagetitle');
?>
chunk
[[!parent_title? &input=`[[*parent]]`]]
[ed. note: badichan last edited this post 12 years, 8 months ago.]
There's a more generic approach here: for getting any field of the current resource's parent (though that may not be what you want).
The reason your original code didn't work is that getParent() returns an array of fields, even if you only ask for one.