Re: [SMARTY] Emails and URLs in smarty template content
| From: | Aliba Sora | Date: | Tue, 28 Jan 2003 22:27:30 +0000 |
| Subject: | Re: [SMARTY] Emails and URLs in smarty template content | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7380@lists.php.net to get a copy of this message | ||
Thanks!
That worked so well. My first customer modifier and it was SUPER easy to
implement. That's again one more area where Smarty shines...
On Tuesday 28 January 2003 13:16, Nichlas Löfdahl wrote:
> Hello!
>
> I use a Smarty-modifier:
>
> function smarty_modifier_linkalize($string)
> {
> return linkalize($string);
> }
>
> function linkalize($text) {
> $text = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i",
> "$1http://$2", $text); //make
> sure there is an
> http:// on all URLs
> $text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i",
> "<A TARGET=\"_blank\" HREF=\"$1\"
> class=link>$1</A>",
> $text); //make all URLs links
>
> $text =
> preg_replace("/[\w-\.]+@(\w+[\w-]+\.){0,3}\w+[\w-]+\.[a-zA-Z]{2,4}\b/i","<a
> href=\"mailto:$0\"
> class=link>$0</a>",$text);
>
> return $text;
> }
>
>
> /Nichlas
> ----- Original Message -----
> From: "Aliba Sora" <smarty-list@lionofzion.com>
> To: <smarty-general@lists.php.net>
> Sent: Tuesday, January 28, 2003 10:10 PM
> Subject: [SMARTY] Emails and URLs in smarty template content
>
> > Hi all,
> >
> > I've been pondering this for a while without enough time to research it,
>
> so I
>
> > thought I would ask the question here.
> >
> > I've a Smarty template that is receiving content from a .php script that
>
> gets
>
> > it from the db. In the PHP script the slashes are stripped and it is
>
> passed
>
> > to the template where it is 'htmlall' escaped.
> >
> > Some of the data from the db is URLs or Email addresses. I was wondering
>
> what
>
> > the Best pratice to turn those into links would be. In the old phplib
>
> system
>
> > that I'm converting from they were just regex'ing them. I would prefer
> > to add a variable modifier in the template if possible....so I'm not sure
> > if
>
> the
>
> > solution is a plugin or just a regex_replace. Any ideas or pre-existing
> > solutions?
> >
> >
> >
> > --
> > Smarty General Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php