I have a parent template like so:
{block "body"}{block "message"}Some stuff{/block}{/block}
and a template that extends said parent template like so:
{extends "parent.tpl"}
{block "body"}
Some content...
{block "message"}{$smarty.block.parent}{/block}
{/block}
and where there's {block "message"}{$smarty.block.parent}{/block}
I'd like to move the contents of the parent block there instead - basically, if a template extends the parent, the message should be displayed right in the body, but if it extends the child, it should be displayed in some other area. Is there a nice way to tackle this problem with Smarty templates?
I'm not sure if I did understand it right. Do you want to display the content of the the "message" block outside the "body" block if "body" is defined in the child?
This could be done as follow:
{block "body"}{block "message"}Some stuff{/block}{/block}
some text...
{if $foo}{$foo}{/if}
and
{extends file='parent.tpl'}
{block "body"}
Some content...
{capture assign=foo}{block "message"}{$smarty.block.parent}{/block}{/capture}
{/block}