phpti icon indicating copy to clipboard operation
phpti copied to clipboard

Multiple blocks with same name... override them all

Open arshaw opened this issue 15 years ago • 1 comments

so you can do something like this...

parent.php:

<title>My Website Title | <?php emptyblock('title') ?></title>
<h1><?php emptyblock('title') ?></h1>

child.php:

<?php startblock('title') ?>Contact<?php endblock() ?>

however, there is an issue when superblock() is called and there are multiple parents (which superblock should it use?) but this feature might be worth it (maybe just choose the first superblock).

arshaw avatar Apr 11 '10 02:04 arshaw

A way to do this is to render the content of the parent block at the specific overriden block, like happens with smarty:

parent.tpl

AAAA
{block "repeated"}
BBBB
{/block}
CCCCC
{block "repeated"}
DDDD
{/block}
EEEE

child.tpl

{block "repeated"}
Overriding <strong>{$smarty.block.parent}</strong> with FFFF
{/block}

The result would be:

AAAA Overriding BBBB FFFF CCCCC Overriding DDDD with FFFF EEEE

JeyDotC avatar Dec 01 '12 19:12 JeyDotC