 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
amitfts Smarty n00b
Joined: 04 Jun 2010 Posts: 1
|
Posted: Fri Jun 04, 2010 6:38 am Post subject: changing session variable in template |
|
|
Hi friends
I have to change the value of session variable after using it in template file
{$smarty.session.popup}
may you help me how can I modified it |
|
| Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 4183 Location: Hamburg / Germany
|
Posted: Fri Jun 04, 2010 10:06 am Post subject: |
|
|
| You have to write a registered function or function plugin to do this job if you really have to modify the session from within the template. |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7047 Location: Lincoln Nebraska, USA
|
Posted: Fri Jun 04, 2010 1:51 pm Post subject: |
|
|
do that in PHP (business logic). otherwise write a plugin to assign it, as session vars are read-only in the template. But you really should handle this in PHP and just assign presentational elements in-template. example:
php:
| Code: | if($_SESSION['popup']) {
$smarty->assign('is_popup',true);
$_SESSION['popup'] = false;
} |
template:
| Code: | {if $is_popup}
...
{/if} |
Here you see the template deals with presentation, and not the underlying business logic (ie. reading/writing session vars) |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|