|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
lojmann Smarty n00b
Joined: 31 Jan 2004 Posts: 1 Location: Malmö, Sweden
|
Posted: Sat Jan 31, 2004 11:20 am Post subject: Using sessions with smarty? |
|
|
Hi,
Is it possible to use sessions in my tpl-files?
I've try but it wount work!
I've try to assign my session vars, but it dosen't work...
Please help me! _________________ /Lojmann |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat Jan 31, 2004 1:48 pm Post subject: |
|
|
I have used sessions with smarty many times. Just use {$smarty.session.var} to get the variable 'var'. _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
gianni Smarty Rookie
Joined: 14 May 2003 Posts: 29 Location: Bari, Italy
|
Posted: Sat Jan 31, 2004 2:08 pm Post subject: |
|
|
Is it possible to use this?
{$smarty.session.object->var}
or this?
{$smarty.session.object->method()} _________________ PHPnews.it Notizie dal mondo PHP e dintorni |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat Jan 31, 2004 3:51 pm Post subject: |
|
|
I would imagin the first is possible, but the second given the nature that PHP serializes the objects variables only would require you to declare a new class and assign the unserialized session variable to it then it would retain all properties as before and you could possibly call methods. I havn't tested it but if my understanding of Smarty is right it should work. _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jan 31, 2004 4:12 pm Post subject: |
|
|
@gianni: the former works since 2.6.0, the latter works not. |
|
Back to top |
|
terryjohnson Smarty Rookie
Joined: 03 Jan 2004 Posts: 9 Location: Chatham, ON, Canada
|
Posted: Wed Feb 04, 2004 9:18 pm Post subject: Session object method call work in foreach, but not alone? |
|
|
I don't understand why $smarty.session.object->getData() does not work but this does:
Code: |
{foreach item=object from=$smarty.session.objectarray}
{$object->getData()}
{/foreach}
|
It is possible to make a direct method call work? It would save a lot assigning objects by reference just to give them a simpler name. |
|
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
|