Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

including dynamic tpl content

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
dmllc
Smarty Rookie


Joined: 15 Oct 2010
Posts: 6

PostPosted: Sun Mar 25, 2012 6:57 pm    Post subject: including dynamic tpl content Reply with quote

smarty n00b here. i need some help trying to figure out how to include a recordset into multiple templates.

i have a php script which queries a db and outputs the results into a template named mod_citylist.tpl. this works fine. i can access this file via the broswer and see the results. the problem is when i try to include mod_citylist.tpl into other templates which need the same data. i get the following errors:

Notice: Undefined index: results in C:\Users\dev\workspace\templates_c\ea66ce8811d4c8679cbd06944e2437ef9a7a8e76.file.mod_citylist.tpl.php on line 30

Notice: Trying to get property of non-object in C:\Users\dev\workspace\templates_c\ea66ce8811d4c8679cbd06944e2437ef9a7a8e76.file.mod_citylist.tpl.php on line 30

i am not sure if i am approaching my design in the right manner or how to fix the problem. any ideas?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Sun Mar 25, 2012 8:28 pm    Post subject: Reply with quote

If you include mod_citylist.tpl into other templates you must also query the db and assign the result.
Back to top
View user's profile Send private message
dmllc
Smarty Rookie


Joined: 15 Oct 2010
Posts: 6

PostPosted: Sun Mar 25, 2012 9:03 pm    Post subject: Reply with quote

if i need to access this results set from other templates throughout the site, should i implement it as a plugin?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 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