Jost
Jost

Reputation: 5840

Template inheritance: remove block that was added in grandparent and appended to in parent

In a smarty template, I have three templates:

base.tpl

{block name="myBlock"}
    base
{/block}

child.tpl

{extends file="base.tpl"}
{block name="myBlock" append}
    child
{/block}

grandchild.tpl

{extends file="child.tpl"}
{block name="myBlock"}{/block}

When rendering grandchild.tpl, the output is

base

So the grandchild-template wants to replace the content of whole block, but only replaces the appended part. How do I delete the whole block?

Related: How to remove content appended to block in parent template?

Upvotes: 0

Views: 882

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

The solution here is in child.tpl change block definition from:

{block name="myBlock" append}
    child
{/block}

into:

{block name="myBlock"}
    {$smarty.block.parent} child
{/block}

Upvotes: 1

Related Questions