Re: [SMARTY] nl2br in a template?

From: Date: Wed, 26 Feb 2003 17:06:02 +0000
Subject: Re: [SMARTY] nl2br in a template?
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8226@lists.php.net to get a copy of this message
Hi, You have a thread in the mailing list about nl2br Regards. Le mer 26/02/2003 à 17:59, Pete a écrit : > Could this function go in the standard distrinution as I'm sure > everyone else uses it > > Pete > > function smarty_modifier_nl2br($message) { > return nl2br($body); > } > > > > > Paul Lockaby wrote: > > gawan wrote: > > > >> Hi > >> > >> I have text fields from a database to display through smarty template. > >> Is there a convenient way to use something similar to php nl2br() > >> to show new lines as <br> tags when in a template? > >> > >> gawan > >> > >> > > > > Yes! Using a plugin for this is ideal. Here is an example: > > > > function smarty_modifier_nl2br($message) { > > return nl2br($body); > > } > > > > Put that in a file by itself, named modifier.nl2br.php and then in your > > template file, simply call it like this: > > > > { $var|nl2br } > > > > And poof(!) $var will have all newlines replaced with <BR>s. You can > > also check out this page right here: > > > > http://smarty.incutio.com/?page=SmartyPlugins > > > > For more ideas on plugins you can use to modify your text. I especially > > like the bbcode2html plugin and use a modified version of it on my own > > site. > > > > Hope that helps! > > ~Paul > > > > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Jean-Michel Juzan jmjuzan@ecreasol.ch Direction Informations & Technologies eCreaSol - NetWork Creative Solutions SARL - http://www.ecreasol.ch/ PGP public keys server : http://www.keyserver.net

Attachment: [application/pgp-signature] signature.asc
« previous php.smarty.general (#8226) next »