block — Defines a block that can be extended by a child template
Using function
<?php
block(string $name)
name: block name, create a new block with that same name in the child template to override it
Now if we render gallery_home we will get this:
{block "page-title"}Gallery home{/block}
{block "content"}
{foreach $images img}
<img src="{$img.url}" alt="{$img.description}" />
{/foreach}
{/block}
The above example will output:
<div id="content">
<img src="/example.jpg" alt="image" />
<img src="/example2.jpg" alt="image" />
<img src="/example3.jpg" alt="image" />
</div>
To sum things up, here is a list of short hints and limitations that apply to template inheritance:
{/}
, you must explicitly do {/block}
{block "name"}...{/block}
parts as possible since it will be as flexible as the amount of blocks it has and this process happens entirely during template compilation so it adds nearly no overhead to the whole process{extends "parent"}
{block}
blocks will be removed{$Tplix.parent}
{$Tplix.parent}
will vary according to each overriden block