Make all Phpnuke News Links Bold, Underline, Open in New Window, and External Links Nofollow

September 12, 2009 by Floppy

For a lot of our themes, we don”t have special classes just for links that are in the news. So it makes them hard to pin point sometimes. So I wrote this little hack and I thought I would share.

Most likely in your current theme’s theme.php file you will find a function called themearticle. Below is an example, but yours may not look exactly like it.

function themearticle ($aid, $informant, $datetime, $title, $thetext, $topic, $topicname, $topicimage, $topictext, $notes) {  //montego - added $notes for RavenNuke
 global $admin, $sid, $tipath, $index;

On a new line after the global call add

//Floppy's Underline and Bold Phnuke News Hack (www.clanthemes.com)
 $thetext = preg_replace('#<a(.*?)</a>#','<strong><u><a$1</a></u></strong>',$thetext);
 //Floppy's Nofollow External Links for Phpnuke News Hack (www.clanthemes.com)
 $your_domain = 'clanthemes.com';//Change this to your domain
 preg_match_all('#href="((http://www.|http://|www.)(.*?))"#',$thetext,$matches);
 foreach($matches[0] as $link){
 if(stristr($link, $your_domain) == false){
 $thetext = str_replace($link, $link.' rel="nofollow" target="_blank"', $thetext);
 }
 }

Save and Upload.  You should be done. If you don’t want it to be nofollow you can remove rel=”nofollow” from the below line.

 $thetext = str_replace($link, $link.' rel="nofollow" target="_blank"', $thetext);

The same goes for opening in a new window. If you don’t want it to be bold or underline you can modify this line.

 $thetext = preg_replace('#<a(.*?)</a>#','<strong><u><a$1</a></u></strong>',$thetext);

Noob Note: Only external links will be nofollow.  If you set your domain correctly all of your links will be followed by search engines.

Example:http://www.clanthemes.com/article398-operation-flashpoint-2-theme-released.html

Related posts:

  1. Nofollow, Bold, and Underline for Forum Links
  2. Tricked Out News 2.4 Released
  3. Nuke Info Mod for Phpnuke
  4. nukeWYSIWYG(tm) 2.6.4 Phpnuke Mod/Hack
  5. Social Bookmarking for Phpnuke