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

setting up plugins directory for easy upgrades?

 
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 -> Installation and Setup
View previous topic :: View next topic  
Author Message
jmarkantes
Smarty n00b


Joined: 23 Mar 2004
Posts: 1

PostPosted: Tue Mar 23, 2004 10:11 am    Post subject: setting up plugins directory for easy upgrades? Reply with quote

Howdy all-

How do you guys manage upgrading smarty, while maintaining custom plugins in addition to the plugins that come with smarty?

I'm starting to write some custom plugins, and also want to keep the existing ones that come with smarty. When I upgrade smarty in the future, normally I just repoint a symlink to the latest smarty directory. But with my own plugins, I'll also need to remember to copy my plugins into the new plugin directory. I could do the other direction and put everything in a seperate plugin directory, but then I'd have to remember to copy the latest plugins from the latest smarty into my custom directory.

I've read through the best practices page on the smarty wiki with no insight. I've also tried assigning multiple plugin directories in my smarty object, seperated by a semicolon, but it doesn't like that. Anyone know if you can have multiple directories assigned there?

Anyways, it's late, I hope this makes sense. Thanks for any help!
Jason
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Mar 23, 2004 10:33 am    Post subject: Reply with quote

If you want to maintain multiple-plugins-dirs you have to make $smarty->plugins_dir an array.
I often do:

[app/config.php]
[php:1:1575bf58f1]
define('BASEDIR', dirname(__FILE__) . '/'); /* applications base */
define('SMARTY_DIR', '....full/path/to/smarty/libs/'); /* smarty's base */
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty;
...
$smarty->plugins_dir = array(BASEDIR . 'plugins',
SMARTY_DIR . 'plugins');
[/php:1:1575bf58f1]

If I switch the "....full/path/to/smarty/libs/" everything else can stay as is.

The order of the elements in plugins_dir also enables me to override Smarty's distribution's plugins: For example: If a function.html_image.php is found in "BASEDIR . 'plugins'" (maybe one with nifty scaling features and without the braindead "dpi"-option Wink ) then that one is preferred over the one in "SMARTY_DIR . 'plugins'".
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


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

PostPosted: Wed Mar 24, 2004 1:00 am    Post subject: Reply with quote

FWIW, I do the same thing as messju (and for the same reason--I can override distribution plugins if I want). What I have found in practice is that I pretty much never override plugins in that way. Still, I like to keep my plugins separate from the distribution plugins, so it is a very useful technique.

However, considering that Smarty searches for plugins based on the directory order, you may want to consider having the Smarty plugins come first if you mainly use those. It probably won't make very much of a difference overall, but it can start to be noticable if you have several layers of plugin directories to search (which I once had for a particular project).

Just a thought.
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 -> Installation and Setup 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