can't get a parent blocks content

瀏覽次數:53 次
跳到第一則未讀訊息

matterk

未讀,
2009年8月26日 中午12:51:112009/8/26
收件者: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

未讀,
2009年8月26日 下午1:49:012009/8/26
收件者: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

未讀,
2009年8月26日 下午3:17:382009/8/26
收件者: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

未讀,
2009年8月26日 下午4:00:572009/8/26
收件者: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

未讀,
2009年8月29日 清晨6:29:352009/8/29
收件者:Smarty Developers
I don't understand. I thought base.tpl IS the parent block.

matterk

未讀,
2009年8月31日 下午3:45:082009/8/31
收件者:Smarty Developers
Yeah, I guess I was just thinking about the inheritance incorrectly.
Thanks!
回覆所有人
回覆作者
轉寄
0 則新訊息