Writting own smarty plugins is very easy. In your smarty based applications, you
can create own plugins when you want to simplify your logic.
Here is a short guideline and an example to write your own smarty pugins:
1. Create plugin file named function.yourpluginname.php in the smarty plugins
directory
2. Define a function named smarty_function_yourpluginname(and parameters
$params, &$smarty)
3. Use this plugin from template file same as the other plugins
Lets say our plugin name is "encloseByText". So our function.encloseByText.php file should contain this:
-------------------------------------------------------------------------------------------------
<?php
function smarty_function_encloseByText($params, &$smarty)
{
$string = $params['string'];
$text = $params['text'];
return $text.$string.$text;
}
?>
----------------------------------------------------------------------------------
And our template file will use this plugin as:
{encloseByText string="InputString" text="delim"}
Output will be : delimInputStringdelim
That's all of creating and using a smarty plugin. This is just an example.
Hope you will enjoy !!
Regards,
Rupom
Join phpResource Group And Enjoy PHPing...
Get amazing travel prices for air and hotel in one click on Yahoo! FareChase