I would like to change the order of parent blocks in a child templates while using the content of the parent blocks.
Example:
parent template:
{block outer}
{block a} ... some long content ...{/block}
{block b} ... some long content ...{/block}
{block c} ... some long content ...{/block}
{/block}
child template:
{extends file="parent:parent.tpl"}
{block outer}
{block c} reuse content of parent block "c" {/block}
{block b} reuse content of parent block "b" {/block}
{block a} reuse content of parent block "a" {/block}
{/block}
I tried using {$smarty.block.parent}
inside block a, b and c:
{extends file="parent:parent.tpl"}
{block outer}
{block c} {$smarty.block.parent} {/block}
{block b} {$smarty.block.parent} {/block}
{block a} {$smarty.block.parent} {/block}
{/block}
In this case {$smarty.block.parent}
contains the content of the parent block "outer".
Is it possible to render the content of the inner blocks a, b and c inside the child template?
Scenario: The contents of blocks a, b and c is really complex and I want to avoid copying and pasting the whole contents from the parent.
Though this is a old post this might be important for the future.
My best attempt at solving this issue is the following:
{extends file="parent:parent.tpl"}
{block a}
{capture a}
{$smarty.block.parent}
{/capture}
{/block}
{block c}
{capture c}
{$smarty.block.parent}
{/capture}
{/block}
{block b}
{$smarty.capture.c}
{$smarty.block.parent}
{$smarty.capture.a}
{/block}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With