Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Isset and Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Maxime
Smarty n00b


Joined: 01 Dec 2010
Posts: 3

PostPosted: Wed Dec 01, 2010 1:56 pm    Post subject: Isset and Smarty Reply with quote

Hello,

I'm trying to use Smarty for my template system.
I'd like to do something like this :
Code:

<?php if (isset($_SESSION['affiliate_id']) AND $_SESSION['affiliate_id'] != '') echo "Toto"; ?>


For example this isn't enough because i don't use isset() and i get php notice.
Code:

{if $smarty.session.affiliate_id != ''}
   toto
{/if}


How can i do the same thing with Smarty ?

Thanks for help.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 01, 2010 2:26 pm    Post subject: Reply with quote

you can use isset() inside IF statements. ideally you would assign values you want to the template instead of directly accessing $_SESSION from the templates. see note:

http://www.smarty.net/docs/en/language.variables.smarty.tpl
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP