|
Re: [SMARTY] Emails and URLs in smarty template content: msg#00404php.smarty.general
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@xxxxxxxxxxxxxx> To: <smarty-general@xxxxxxxxxxxxx> 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 -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [SMARTY] Emails and URLs in smarty template content: 00404, Aliba Sora |
|---|---|
| Next by Date: | Re: [SMARTY] Emails and URLs in smarty template content: 00404, Aliba Sora |
| Previous by Thread: | [SMARTY] Emails and URLs in smarty template contenti: 00404, Aliba Sora |
| Next by Thread: | Re: [SMARTY] Emails and URLs in smarty template content: 00404, Aliba Sora |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |