Links in video description

Discuss of clipshare script, custom programming, templates or anything related to this video script

Links in video description

Postby dargre » Thu Jan 14, 2010 11:44 pm

Was already posted on clipshare forum.

Many uploaders enter some URLs into video description.
So I'm sure many webmasters here would be happy to change it automatically into clickable links at least for video descriptiion on view video page.
So you may try this:

1. Open any text editor (can be notepad) and enter this:
Code: Select all
<?php
function smarty_modifier_dolink($text)
{
   $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
   $ret = ' ' . $text;
   $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);
   $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);
   //$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
   $ret = substr($ret, 1);
   return $ret;
}
?>

2. Save this as file "modifier.dolink.php"

3. Upload to "include/smarty/libs/plugins" (or "smarty/libs/plugins") folder.

4. Edit file "templates/view_video.tpl"

5. Find line where text "description" appears.

In default script version this is: {$vinfo[0].description|escape:'html'}

Add new modifier at the end: {$vinfo[0].description|escape:'html'|dolink}

NOTICE

In code posted in red color I set "comment" double slash for php line that allows to change email address into clickable one. If you wish also to have clickable emails - just remove this double slash.

I set safe "nofollow" attribute for links - you may change it if you wish and know how. Same with window target.
If you want some style for link - you may add it, but better do that as CSS style for description text.

Code is fine, but as with everything - you can't be 100% sure so it will work on some weird links.
All changes you do on your own risk.
Thank you,
Nuevolab Team
dargre
 
Posts: 299
Joined: Mon Sep 07, 2009 3:47 am

Return to Clipshare

Who is online

Users browsing this forum: No registered users and 0 guests