Home arrow Tutorials arrow Add NoFollow attribute to Joomla menu items

Web Development

Welcome to Web Development section. Please choose a category. 
 
  • Hrvatski tutorijali
    Ovdje su objavljeni razni tutorijali na hrvatskom jeziku na temu PC, programiranje, web development, savjeti, trikovi, optreba racunala itd.
  • Tips / Tricks
    Articles about various tips and tricks concerning Windows, Linux and other OS usage.
  • JavaScripts
    Code snippets, tutorials and tricks for JavaScrip language.
  • PHP & MySQL
    Tutorials, code examples, tips and tricks for PHP and MySQL development.
  • Tutorials
    Place for tutorials about using various application in best and simplest way.
Add NoFollow attribute to Joomla menu items PDF Print E-mail
(2 votes)

Unfortunately NoFollow mambot will not work on menu items in your Joomla because there is no Mambot event I could attach parsing functions to.
There fore I came up with an idea to solve the issue. You'll have to edit your Joomla source files. Please note that this procedure requires some skills. You do that on your own risk.

Basically you need to change few lines of code. This tutorial is tested on joomla version 1.0.13 Unfortunately NoFollow mambot will not work on menu items in your Joomla because there is no Mambot event I could attach parsing functions to.
There fore I came up with an idea to solve the issue. You'll have to edit your Joomla source files. Please note that this procedure requires some skills. You do that on your own risk.

Basically you need to change few lines of code. This tutorial is tested on joomla version 1.0.13
joomla_1.0.13

STEP 1

Open your Joomla root directory and open file modules/mod_mainmenu.php  and search for the following code (should be around line #112)
you should find something like this:
$mitem->name = stripslashes( ampReplace($mitem->name) );

add this code right bellow

// hack by vitez-studios.com
$mitem->nofollow = ((strpos($mitem->link,'http://') === 0 || strpos($mitem->link,'https://') === 0) && strpos($mitem->link,$mosConfig_live_site) === false) ? ' rel="nofollow" ' : '';

STEP 2

Then find the following code (should be few lines bellow)

$txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';

Replace it with following code:

$txt = '<a href="'. $mitem->link .'"'.$mitem->nofollow.' target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';

STEP 3

Find the following code (also few lines bellow)
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';

Replace it with following code:

$txt = '<a href="'. $mitem->link .'"'.$mitem->nofollow.' class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';

Thats it!
If you have cache enabled please clean all your caches to see changes in code.

 
< Prev   Next >
What's your favorite Internet browser?
 

Login






Lost Password?

Tools

Coming soon...

Syndicate