|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Apr 03, 2009 4:19 pm Post subject: Couple of new functions |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Apr 04, 2009 4:15 pm Post subject: |
|
|
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 |
|
|
|
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
|