can't get a parent blocks content

53 views
Skip to the first unread message

matterk

unread,
26 Aug 2009, 12:51:1126/08/2009
to Smarty Developers
I posted in the forum but the mailing list might be a better spot.

I found the syntax here:
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=15162

Which says {$smarty.block.foo.parent} should give you the parent
blocks content.

But after looking in
Smarty_Internal_Compile_Internal_Smarty_Var::compile() it looks like
the syntax for accessing a parent blocks content is something like
this?

{$smarty.block.parent.foo}

But regardless of which one I use I still can't seem to get the
content.

After a little more debugging the block_data[] (in
Smarty_Internal_Compile_Internal_Smarty_Var::compile() line #87) array
seems to be empty.

Any ideas?

U.Tews

unread,
26 Aug 2009, 13:49:0126/08/2009
to Smarty Developers
{$smarty.block.parent.foo} is the correct syntax.

Could you please post how your templates look like to trace your main
problem down?

Regards Uwe

matterk

unread,
26 Aug 2009, 15:17:3826/08/2009
to Smarty Developers
Using trunk/distribution/demo/index.php I changed php:index_view.php
to index.tpl

file: base.tpl
{block name="content"}
this is base.tpl
{/block}

file: index.tpl
{extend file="base.tpl"}
{block name="content"}
this is index.tpl
{$smarty.block.parent.content}
{/block}

output:
this is index.tpl

Although I also just found this syntax, which seems to work.

{block name="content" append=true}new content{/block}

U.Tews

unread,
26 Aug 2009, 16:00:5726/08/2009
to Smarty Developers

You had the tag in the wrong file.

file: base.tpl
{block name="content"}
{$smarty.block.parent.content}
this is base.tpl
{/block}

Doug

unread,
29 Aug 2009, 06:29:3529/08/2009
to Smarty Developers
I don't understand. I thought base.tpl IS the parent block.

matterk

unread,
31 Aug 2009, 15:45:0831/08/2009
to Smarty Developers
Yeah, I guess I was just thinking about the inheritance incorrectly.
Thanks!
Reply all
Reply to author
Forward
0 new messages