Hi everyone,
I am trying to output the page title of a document’s parent onto a page but I’m not having much luck.
I have used [*parent*] in the main template, which outputs the id of the documents parent, I can’t find any parameters which would allow me to output the pagetitle.
I have seen the code $parent = $modx->getParent(55,1,’pagetitle’); in the documentation but I don’t know where to put in this code. Does it or can it go into a chunk, snippet or template variable?
Would I have to change the code to: $parent = $modx->getParent([*id*],1,’pagetitle’);
Thanks,
Mark
-
MODX Staff
- 10,725 Posts
Search for the getField snippet. You can get a property for another document with this, and simply pass it the fieldname and document id, i.e. [*parent*], you want to get the value from.
Thanks OpenGeek,
With regard to the code $parent = $modx->getParent(55,1,’pagetitle’); can it go inside a TV or a chunk or snippet?
What is the best practice?
I will need this kind of functionality in the future, and I couldn’t find info on this in the docs...
Can’t answer that, but as Jason said, try with GetField
[tt][!GetField? &docid=`[*parent*]` &field=`pagetitle`!][/tt]
:)
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id