|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
libera Smarty n00b
Joined: 20 Jul 2005 Posts: 2
|
Posted: Wed Jul 20, 2005 9:22 pm Post subject: plugin that change "http://www.smarty.php.net" int |
|
|
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 |
|
spajus Smarty n00b
Joined: 21 Jun 2005 Posts: 4
|
Posted: Thu Jul 21, 2005 7:30 am Post subject: |
|
|
i believe you should
Code: |
$smarty -> register_outputfilter("href2link");
$smarty-> display('topic.tpl');
$smarty->unregister_outputfilter('href2link');
|
|
|
Back to top |
|
libera Smarty n00b
Joined: 20 Jul 2005 Posts: 2
|
Posted: Thu Jul 21, 2005 10:31 am Post subject: |
|
|
Thank you very much |
|
Back to top |
|
|
|
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
|