Page 1 of 1

Thoughts on how plugins are loaded

Posted: Tue Apr 19, 2005 2:40 am
by SRTech
I could be wrong about a couple things here, let me know if I am.

The default way smarty handles plugins, is that they are loaded only if they are used in the template. CMS however, loads all the plugins, used or not. This could cause some serious speed issues if you developed numerous special plugins.

To solve this problem, several things could be done, but here is one idea. Add the plugin directory to the $smarty->plugins_dir array. This would require, however, that all the plugin function names be renamed from smarty_cms_function_* to smarty_function_* as the "smarty_function" is hard coded into the Smarty compiler class (line 781, Smarty_Compiler.class.php) To work around this, it would probably be best to override the _compile_custom_tag() in one of the smarty extension classes, as long as the smarty source for this function is monitored.

Hope this makes some sense.

Re: Thoughts on how plugins are loaded

Posted: Tue Apr 19, 2005 9:27 am
by Ted
Well, there is one main reason why CMS does it's own plugin loading.  Cacheing.  I wanted to insure that all of the CMS plugins didn't cache (particularly cms_module) as it would cause some real issues with the dynamic nature of what we're doing.

If you know enough about the internals of Smarty and have a good way to solve this fact, I'm all for it.  That was a hack I did somewhere around version 0.3/0.4, and I'm sure there is a better way now.

Re: Thoughts on how plugins are loaded

Posted: Tue Apr 19, 2005 6:58 pm
by SRTech
Have a couple ideas for this. Will try some things and report back later.

Re: Thoughts on how plugins are loaded

Posted: Tue Apr 19, 2005 7:03 pm
by Ted
Ok, cool.  Performance is always a good thing.

Don't forget about user defined tags either.  They're stored in the database and converted to smarty plugins on the fly...