Re[2]: [SMARTY] plugin & assign weirdness

From: Date: Tue, 17 Feb 2004 14:14:00 +0000
Subject: Re[2]: [SMARTY] plugin & assign weirdness
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10968@lists.php.net to get a copy of this message
Thanks a lot messju (and Luc), I'm going to try it out right away. You're right, I think the manual is not very clear about this. Thanks a lot for your time and help! greetings, --David Spreekmeester ___________________________________________ here's Messju's answer to my problem: "The scope of changes to template-variables is local to the included template. The template-variables are restored when the included template is done. Maybe this should be stated more clear on the manual-page for {include}. There is no really easy way around that. One trick (somebody suggested some time ago, but i forgot who and where, sorry): If you know in advance which variables you want to handle as globals (= which ones should be changeable by included templates) is: Assign them with assign_by_ref() from php. Then they are handled as references in the template and the included-template assigns really the same variable as the including one uses. If you don't have values to assign, you can simply do somthing like: $smarty->assign_by_ref('var1', $dummy = null); unset($dummy); $smarty->assign_by_ref('var2', $dummy = null); unset($dummy); /* {$var1} and {$var2} should be changeable by included tpls now */ Another way would be if you don't use {include} but write your own plugin that uses $smarty->fetch() to retrieve an included template."

« previous php.smarty.general (#10968) next »