Hi there,
I have problem with using content from parent page in child pages (two different templates).
My site tree looks like this:
Page_1 (Template_1.ss)
--- Page_2 (Template_2.ss)
------- Page_3 (Template_3.ss)
------- Page_4 (Template_3.ss)
------- Page_5 (Template_3.ss)
It is possible to use content from Page_1 and replicate it across all child and grandchild pages (2, 3, 4, 5 etc.) without using fields in those child/grandchild pages in CMS? I’ve tried renderWith method but I don’t know how to use it properly. Is anyone used something like this and could provide some clues or snippet?
UPDATE:
It's preety easy actually. In 1st template you could declare custom fields with some content and then in child templates:
<div>
<h2>$Parent.MyStuff</h2>
<p>$Parent.MyStuffAlso</p>
</div>
or with include:
<% with Parent %>
<% include SomeStuff %>
<% end_with %>
Documentation link:
https://docs.silverstripe.org/en/3.3/developer_guides/templates/common_variables/#parent
Cheers,
Darek.