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

Couple of new functions

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
mohrt
Administrator


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

PostPosted: Fri Apr 03, 2009 4:19 pm    Post subject: Couple of new functions Reply with quote

Uwe Tews just added a couple of new useful functions to Smarty 3 Alpha SVN:

Code:
$smarty->registerTemplateDefaultHander('myTplHandler');
$smarty->registerPluginDefaultHandler('myPluginHandler');


registerTemplateDefaultHander() sets function/method that handles fetching a template on-the-fly if one does not exist in the template directory. This is much the same as the Smarty 2 default template handler.

registerPluginDefaultHandler() sets a function/method that will take care of registering a plugin on-the-fly if one is not found in the plugins_dir or already registered.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Sat Apr 04, 2009 4:15 pm    Post subject: Reply with quote

Here some more details about the usage

Quote:
$smarty->registerTemplateDefaultHander('myTplHandler');

registerTemplateDefaultHander() sets function/method that handles fetching a template on-the-fly if one does not exist in the template directory. This is much the same as the Smarty 2 default template handler.

function myTplHandler($resource_type, $resource_name, &$template_source, &$template_timestamp, &$tpl)
The parameters are:
$resource_type = the resource type of the failing template (for example 'file').
$resource_name = the name of the failing template (for example 'foo.tpl')
&$template_source = this parameter by reference must be loaded by the template default handler with the template source which shall be displayed.
$template_timestamp = timestamp to be used for template output
&$tpl = template object

The handler must return true if it has loaded template source code. Otherwise it must return with false.

If template source code was loaded Smarty will compile and display it. The compiled code will stored under the name of the failing template and if caching is enabled the output is also cached.

Code:
$smarty->registerPluginDefaultHandler('myPluginHandler');

registerPluginDefaultHandler() sets a function/method that will take care of registering a plugin on-the-fly if one is not found in the plugins_dir or already registered.

function myPluginHandler ($name, $type, &$tpl)
$name = name of plugin not found
$type = type of plupgin (for example 'function')
&$tpl = template object.

The plugin default handler must register a pluging and return true. If it can not resgister a plugin it must return false.
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 -> 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