Hi is it possible to get the properties of a parent page from a child page. So say i have a mainHeader property in the parent page, how can i get these propeties in the child page? I've found how to get the parentID using @parentID but not sure how to access the property mainHeader from this.
Warren is talking about the recursive="true" parameter. This works if the same property exists in the parent page as well as in the childpage.
For example if you have a mainHeader property in your childpage which is empty, the recursive="true" parameter will make Umbraco look for the same property on the parentpage. If it does contain a value on the parentpage it will render it in the childpage.
But what about properties that do not exist on a certain childpage? But do exist on the parentpage? I guess you can do it with an xpath node, something like ./ to go up in the XML. However I did not use this in Umbraco myself yet.
Roel thanks for explaining my snippet. In regards to the property not even existing on the child page but on the parent that will work perfectly fine as well. (As far as I remember)
It will basically walk all the way up the tree, going through each parent until it finds the propety and a value to ouput/display. I hope that makes sense.
- created a parentpage - added property mainHeader - added property bodyText - created a childpage under the parentpage - added property bodyText - in template of both the parentpage and the childpage I inserted umbraco:item fields for mainHeader and bodyText except in the childpage template I made the mainHeader field recursive
As a result the mainHeader field is also rendered into the childpage, which was loaded from the parentpage by Umbraco.
Parent page properties
Hi is it possible to get the properties of a parent page from a child page. So say i have a mainHeader property in the parent page, how can i get these propeties in the child page? I've found how to get the parentID using @parentID but not sure how to access the property mainHeader from this.
As an umbraco:item filed in your masterpage use this:
Warren is talking about the recursive="true" parameter. This works if the same property exists in the parent page as well as in the childpage.
For example if you have a mainHeader property in your childpage which is empty, the recursive="true" parameter will make Umbraco look for the same property on the parentpage. If it does contain a value on the parentpage it will render it in the childpage.
But what about properties that do not exist on a certain childpage? But do exist on the parentpage? I guess you can do it with an xpath node, something like ./ to go up in the XML. However I did not use this in Umbraco myself yet.
Roel thanks for explaining my snippet.
In regards to the property not even existing on the child page but on the parent that will work perfectly fine as well. (As far as I remember)
It will basically walk all the way up the tree, going through each parent until it finds the propety and a value to ouput/display.
I hope that makes sense.
Ok, didn't know that. So no playing around with Xpath to move up in the XML. Will give this a try this evening. Thanks.
No problem report back here just in case I am wrong. Not used it for a little while.
It works, here is what I did:
- created a parentpage
- added property mainHeader
- added property bodyText
- created a childpage under the parentpage
- added property bodyText
- in template of both the parentpage and the childpage I inserted umbraco:item fields for mainHeader and bodyText except in the childpage template I made the mainHeader field recursive
As a result the mainHeader field is also rendered into the childpage, which was loaded from the parentpage by Umbraco.
is working on a reply...