Thursday, 15 August 2013

Access smarty loop property in included file?

Access smarty loop property in included file?

When using smarty it provides a few useful @properties on the looping key
such as @first @last and @iteration.
But it seems that in loops that look like
{foreach $collection as $item}
{include file="something_else.tpl"}
{/foreach}
We seem to lose the @properties.
If I want access to those properties is there a more elegant way than
passing all the properties to the included file?
{foreach $collection as $item}
{include file="something_else.tpl" first=$item@first last=$item@last
iter...}
{/foreach}

No comments:

Post a Comment