RE: [PHP] Smarty functions help
| From: | Daniel Masson | Date: | Tue, 29 Oct 2002 16:25:16 +0000 |
| Subject: | RE: [PHP] Smarty functions help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-121891@lists.php.net to get a copy of this message | ||
Thanks a lot man !! It worked perfecly !!
> Im using smarty template engine .. Id like to know if theres a way to
> place php functions, specifically nl2br(), into smarty templates ..
> Not in php script that calls smarty class.
Take a look at the modules/ folder in Smarty. You can create your own
modifier to use in your templates.
You'd want to make a file called modifier.nl2br.php
and have it's contents something like this:
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: nl2br
* Purpose: add <br /> to all newlines in string
* -------------------------------------------------------------
*/
function smarty_modifier_nl2br($string)
{
return nl2br($string);
}
?>
and then you'd display your value like {$value|nl2br} in the templates.
You could just use the nl2br() function in your assign(), too:
$smarty->assign('text',nl2br($text));
---John Holmes...