I use twig templates in a thin framework. I have a page.phtml template that splits an array of data and has several subblocks designed to be overridden for each element, such as pagination of users, events, orders, etc.
page.phtml
<div class="page"> {% block block1 %}default content{% endblock %} <ul> ... </ul> {% block block2 %}{% endblock %} </div>
I have an event.phtml template that includes page.phtml and adds other content to the page; it also overrides the contents of the default page block
event.phtml
<html> <body> <h1>Event Page</h1> {% embed "page.phtml" %} {% block block1 %}event page content{% endblock %} {% endembed %} </body> </html>
I have a custom event page that only requires changing a few blocks of event pages, so I extended event.phtml like this
custom_event.phtml
{% extends "event.phtml" %} {% block block2 %}overridden value{% endblock %}
and it is expected that the overridden content of block2 will appear in the page.phtml template embedded by the parent template. I can output the value of block2 in the parent template there too, but in the inline template this is not so. I tried explicitly passing the block to event.phtml in the attachment, e.g.
{%embed "page.phtml" %} {% block block2 %}{{parent()}}{% endblock %} ... {% endembed %}
But that didn't make any difference. How to get the redefined block2 from the custom_event.phtml template throughout the extended event.phtml template and into the built-in page.phtml template?
extend block templates twig embed
John f
source share