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

Fetch information from templates rather than feeding them.

 
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
Chavez
Smarty Rookie


Joined: 08 Jul 2003
Posts: 6

PostPosted: Tue Jul 08, 2003 12:06 pm    Post subject: Fetch information from templates rather than feeding them. Reply with quote

Hi!

I'm constructing one of my first Smarty-projects and I have one question for you guys (and possible - girls). I don't know if it's I real problem or if I am to thick to figure out how to do Wink

I have a design consisting of one menu at the top of the site, beneath it I have one table holding two columns. The right column is for the “main information” and the left is for some nice little “information boxes”. I have planned to have one template file for each and every box, and then pass an array from PHP to Smarty including all the filenames of the template files that are going to be displayed in the column. In the template a section block irritates over the array and include the appropriate template-files.

So far so good, right? But the problem arose when I realised that these boxes needed to be feed with information from PHP. They include some figures that I need to query my database for in order to get hold of. Anyone who has some idea of a nice way to do so, to fetch information from templates rather than feed them with it?

Of course I could include a bunch of .php files to do the fetching work before I use $smary->display(), but I find it to be a quite ugly method. Am I wrong?

I realise that this may be a real confusing thread, but please give me your opinion on this. I need some help to straighten up things Wink
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Tue Jul 08, 2003 8:05 pm    Post subject: Reply with quote

well, you can pass information to templates using parameters on the {include} ie.

{inlcude file=template.tpl my_custom_var1=$MyData1 my_custom_var2=$MyData2}

is that what you are looking for?
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 -> 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