symfony - Symfony2 layout composition or inheritance -
I can not understand some principles about layout structure in sf2
I have this app / namespace / my bundle / resource / view / bay.html template:
{% extends ':: base.html.twig'% } {% Block title%} main title {% block subtitle {% Endblock%} {% endblock%} {% block head%} & lt; H1 & gt; Pleasurectite & lt; / H1> {% Endblock%} {% block entity%} {% endblock%} {% block sidebar%} {% Endblock%} I head.html.twig to change head block How to make Currently I have this app / bundle / resource / view / head The template is:
{% expanded 'AppNamespaceMyBundle :: layout.html.twig'%} {% block head -%} & lt; H1 & gt; Main title & lt; / H1> {% Endblock%} Then I load a page with this index.html.twig:
{% extends' AppNamespaceMyBundle: : Layout.html '%} {% Block Subtitle%} | Categories {% endblock%} {% Block Body -%} & lt; H1 & gt; Categories list & lt; / H1> & Lt; Table class = "record_list" & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; Id & lt; / Th & gt; & Lt; Th & gt; Text & lt; / Th & gt; & Lt; Th & gt; Action & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; {% Entity in entity%} & lt; Tr & gt; & Lt; Td> & Lt; A href = "{{path ('category_show', {'id': entity.id}}}}" {{entity.id}} & lt; / td & gt; ; & Lt; td & gt; {{entity.text}} & lt; / td> & lt; TD & gt; & lt; ul & gt; & lt; li & gt; & lt; a href = "{{Path ('category_show', {'id': entity.id}}}} & gt; Show & lt; / a & gt; & lt; / li & gt; & lt; li & gt; Lt; a href = "{{path ('category_edit', {'id': entity.id}}}}"> edit gt; & lt; / li & gt; & lt ; / Ul> gt; & lt; / Td & gt; & lt; / tr & gt; {% Endfor%} & lt; / tbody & gt; & gt; Table & gt; & lt; ul & gt;
Create a new entry & lt; / a & gt; / Ul> {% Endblock%} And here I would rather say "Place instead of" main title " HolderTit ", which means that head.html.twig is not used. How do I use that head.html.twig in layout.html.twig? < P>
What are you explaining, I think you want to present layout + key in your index.
You can use the following Schema: Layout & lt; Enhanced & gt; Head & lt; Enhanced & gt; Index . In this way, when you render the index, tig will present both the head and the layout. Another solution is to use.
PS: You can not extend head and layout in both index file, as Twig says: Template legacy is one of the most powerful twig features, but it is limited to single legacy;
Comments
Post a Comment