Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

plugin that change "http://www.smarty.php.net" int

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
libera
Smarty n00b


Joined: 20 Jul 2005
Posts: 2

PostPosted: Wed Jul 20, 2005 9:22 pm    Post subject: plugin that change "http://www.smarty.php.net" int Reply with quote

Hi.

Is there a plugin that change links into hyperlink ?
ex.
I have http://www.smarty.php.net and I want that plugin find it into the string and change into <A href="http://www.smarty.php.net.pl"> - the same with e-mail adress

I was trying to use function;
Code:
function href2link($text, &$smarty) { 
  $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" TARGET=\"_blank\">\\0</a>", $text);
 
  $text = ereg_replace("[[:alnum:].]+@([[:alnum:]]+\\.)*[[:alnum:]]+","<a href=\"mailto:\\0\">\\0</a>", $text);
 
  return $text;
 
}


and in php;


Code:
$smarty -> register_outputfilter("href2link");
$smarty -> display('topic.tpl');


- but then - any next tpl is using this function and it is not good.
I want to change links into hyperlinks only in topic.tpl

Please help

liberator
Back to top
View user's profile Send private message
spajus
Smarty n00b


Joined: 21 Jun 2005
Posts: 4

PostPosted: Thu Jul 21, 2005 7:30 am    Post subject: Reply with quote

i believe you should

Code:

$smarty -> register_outputfilter("href2link");
$smarty-> display('topic.tpl');
$smarty->unregister_outputfilter('href2link');
Back to top
View user's profile Send private message
libera
Smarty n00b


Joined: 20 Jul 2005
Posts: 2

PostPosted: Thu Jul 21, 2005 10:31 am    Post subject: Reply with quote

Thank you very much Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP