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

.tpl from database instead from files?

 
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
jay
Smarty n00b


Joined: 08 Apr 2005
Posts: 3

PostPosted: Fri Apr 08, 2005 4:55 pm    Post subject: .tpl from database instead from files? Reply with quote

Is it possible to load templates from a database?
somethingh like
Code:
$smarty->display($template_variable);

instead of
Code:
$smarty->display('template.tpl');

?[/code]
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Fri Apr 08, 2005 5:14 pm    Post subject: Reply with quote

Sure thing:

http://smarty.php.net/manual/en/template.resources.php
Back to top
View user's profile Send private message
lucianl
Smarty n00b


Joined: 10 Apr 2005
Posts: 2
Location: Iasi, Romania

PostPosted: Sun Apr 10, 2005 12:18 pm    Post subject: Not so sure about that... Reply with quote

I will not be so sure about that, i tried to use the method display taking as argument a database resource, something like $my_smarty->display($template_to serve), where $template_to_serve = "db:$template".
Working this way isn't accepted by Smarty engine, still trying to figure out the problem.
However, if I use directly $my_smarty->display("db:index"), where 'index' is the name of the template, it works.
Any idea? Idea
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
boots
Administrator


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

PostPosted: Sun Apr 10, 2005 7:38 pm    Post subject: Reply with quote

hmmm. It works for me. Can you demonstrate your problem? ie. post your resource and sample (and failed) cases?
Back to top
View user's profile Send private message
lucianl
Smarty n00b


Joined: 10 Apr 2005
Posts: 2
Location: Iasi, Romania

PostPosted: Mon Apr 11, 2005 7:30 pm    Post subject: Problem seemed to be solved... Reply with quote

Hello!...

Thanx for quick answer and sorry for my delay.

I have a class that, depending of the URI, had to load a certain template from database.
I had rewritten the class and its methods, and now it works.
In previous one, the template was loaded, in that template some variables were assigned, and the same template is used for display() method.
Still don't know why it works now, the code it's the same for 90%.

Thanx a lot!...Happy coding!

One more thing : I have a class that is registering as resource a database. Everything is ok for now, but if I have another class that extends the first class, that resource is not longer available for extended class.I have to implement it again...Sad
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
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