Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is not a good idea, because not every template has to extend a layout: there are some “system” templates like <code>form_div_layout.html.twig</code> that are not meant to extend anything. Besides, not every template you write has to extend a layout; you'll encounter a lot of use cases for small embeddable templates to reference from other templates. </p> <p>If you will try to force a layout on each template, you'll have to write some logic to exclude “system” and embeddable templates so that they don't extend anything, and you'll have to do the same for your layout template too, so that it doesn't extend itself infinitely. In this case you'll reverse the problem: instead of defining explicitly which layout to extend in each template, you'll have to explicitly state which templates should <em>not</em> extend your layout. This will get very messy very fast.</p> <p>To grasp this idea more completely, you need to know that, behind the scenes, templates are really just PHP classes. Does it make sense to you to make a particular class the parent for every other classes, and then explicitly state which classes should <em>not</em> extend this parent?</p> <p>But if I haven't convinced you not to go this way, there is a Twig setting which lets you set the base template class for all templates:</p> <pre><code>twig: base_template_class: Your\Layout\ClassName\Here </code></pre> <p>You can extend <code>\Twig_Template</code> or implement <code>\Twig_TemplateInterface</code> and have some “fun” for several hours, after which I hope you'll be convinced to abandon this idea whatsoever. Good luck. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload