Include files modifying values passed to them
| From: | Mark Rogers | Date: | Sat, 17 Apr 2004 16:39:50 +0000 |
| Subject: | Include files modifying values passed to them | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11280@lists.php.net to get a copy of this message | ||
If I pass values to an included template, which changes them, those changes
are (quite rightly) lost when control returns to the calling template.
I have a situation where it would be very helpful for this not to be the
case, however. What is the easiest way to achieve this?
Eg, I want a mechanism where in the following example the second {$test}
shows 2:
---main.tpl---
{assign var=test value=1}
{$test}
{include file="sub.tpl"}
{$test}
---sub.tpl---
{assign var=test value=2}
PS: I know this would not be a good thing in general! I'm assuming I should
write an alternative to {assign}, maybe {global} or something? Or can I
return a value from the included template somehow? Or pass a value by
reference to an included template?
Anyway, I'm sure I can find _a_ way to do it, I'd just appreciate
suggestions as to the _best_ way.
Mark Rogers