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

retrieve the data in {php}

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
tuntun
Smarty n00b


Joined: 24 Oct 2006
Posts: 1

PostPosted: Tue Oct 24, 2006 6:41 pm    Post subject: retrieve the data in {php} Reply with quote

I am tring to write a php function that's called from a smarty .tpl file.

there is a variable called $entry.id in smarty that I need to retrieve
from within {php} {/php} , how can i do it ? please let me know...



=========

my entry id is { $entry.id }

{php}

global $entry.id; // this doesn't work


my_function ( $myid, $another_variable );

{/php}


============
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Oct 24, 2006 6:46 pm    Post subject: Reply with quote

Code:
$entry = $this->get_template_vars('entry');
echo $entry['id'];

see: get_template_vars() in the manual.

Now that you know, don't. {php} in-template is bad form. Better to use a plugin or pre-calculate before sending data to the template.
Back to top
View user's profile Send private message
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 -> Tips and Tricks 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