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

config datas from database

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


Joined: 02 Jun 2003
Posts: 2

PostPosted: Mon Jun 02, 2003 4:06 pm    Post subject: config datas from database Reply with quote

in this thread http://www.phpinsider.com/smarty-forum/viewtopic.php?t=13&highlight=config+data+database I read it doesn't work until now.

I want to know if anyone have written a function which works like {config_load ....} but using a database?

Yesterday, I tried to do this. But unfortunately it didn't work. Sad
Back to top
View user's profile Send private message
xuguoxin
Smarty n00b


Joined: 18 Apr 2003
Posts: 3

PostPosted: Fri Jun 06, 2003 10:02 am    Post subject: Re: config datas from database Reply with quote

webstar wrote:
in this thread (http://www.phpinsider.com/smarty-forum/viewtopic.php?t=13&highlight=config+data+database) I read it doesn't work until now.

I want to know if anyone have written a function which works like {config_load ....} but using a database?

Yesterday, I tried to do this. But unfortunately it didn't work. Sad


Very Happy it is my problem
Back to top
View user's profile Send private message
[SuB]
Smarty Rookie


Joined: 18 Jun 2003
Posts: 5

PostPosted: Wed Jun 18, 2003 9:26 am    Post subject: Reply with quote

Hi guys,

I just started using Smarty in one of our remotely hosted applications, and this feature is critical to me too.

I intend to put it into my extension class, so I will post the code here when I'm done... probably be in the next few days or so.

I will also submit it to the Smarty team and see if it helps them.
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Wed Jun 18, 2003 7:46 pm    Post subject: Reply with quote

I once did something similar, but I write to mention that the developers are indeed working to try to get config_files to use resources. When it will happen, I don't know Sad

Good luck.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jun 18, 2003 8:26 pm    Post subject: Reply with quote

It isn't in the core yet... that will probably be a little ways off yet. You can roll your own function, or extend the Config_File class to do what you need.

Monte
Back to top
View user's profile Send private message Visit poster's website
[SuB]
Smarty Rookie


Joined: 18 Jun 2003
Posts: 5

PostPosted: Tue Jul 08, 2003 6:41 am    Post subject: Reply with quote

Is it hard to implement?
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 7:40 am    Post subject: Reply with quote

Quote:
Is it hard to implement?


If you mean to implement yourself, it is--straightforward. The main things you need to do are:

1) Create a new configuration class for your storage type. If your new class extends Config_File (current cvs) then you probably only need to override load_file() to deal with your specific storage type. Your class file should be stored in your Smarty dir and should be named using the same convention as used by Config_file.class.php.

2) set $smarty->config_class = 'your_class' when Smarty is instantiated (for example, in your custom Smarty class' constructor).

At this point, Smarty will now use your custom config class for config_load. If you want to enable multiple handling types (similar to resources, eg. 'db:default') then there is more work to do--more too than I list here. In this case, you will have to create a modified version of the default function plugin, function.config_load.php. Instead of using a resource naming scheme (which you can probably rig with some work) it is simpler to control the config class selection with a new custom parameter to config_load. There are certain issues to be considered (eg. managing instances of various config classes) which make this additional step less appealing.

Awhile ago I did a small experiment against 2.5.0 to support multiple types. I could probably find it if I looked around. It could be a starting point if you decided to support multiple types, but I would suggest trying the simpler approach. If you only intend to load configuration data from a single storage type, then steps 1 and 2 should be sufficient.

Good Luck!
Back to top
View user's profile Send private message
[SuB]
Smarty Rookie


Joined: 18 Jun 2003
Posts: 5

PostPosted: Tue Jul 08, 2003 10:23 am    Post subject: Reply with quote

Seems simple enough... another testament to the good design of Smarty.

As a follow on, what's the reason it's not slated for short term inclusion into the core Smarty code? I presume cause you will want it to be a robust feature and not just a small add on?
Back to top
View user's profile Send private message
juchen
Smarty n00b


Joined: 29 Aug 2003
Posts: 3

PostPosted: Thu Oct 30, 2003 3:15 am    Post subject: Reply with quote

This is a problem!
Back to top
View user's profile Send private message Visit poster's website
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