You are here:  » Add rel="nofollow" to hard coded links in array

Support Forum



Add rel="nofollow" to hard coded links in array

Submitted by npaitken on Tue, 2009-02-10 09:45 in

Hi David,

Do you know how to add rel="nofollow" tag to links, like below, in an array. I've decided to nofollow any hard-coded links that go to a search.php.

$atoz["items"][] = array("name" => "Artwork", "href" => "category/Artwork/");
$atoz["items"][] = array("name" => "Ball Markers", "href" => "search.php?q=ball+marker");
$atoz["items"][] = array("name" => "Books, CDs & DVDs", "href" => "category/Books-CDs-DVDs/");
$atoz["items"][] = array("name" => "Cleaners", "href" => "search.php?q=cleaner");
$atoz["items"][] = array("name" => "Divot Tool", "href" => "search.php?q=divot");

Many thanks,
Neil

Submitted by support on Tue, 2009-02-10 10:54

Hi Neil,

Ordinarily, this would require a mod to atoz.php itself, however if you only want to have these particular links nofollow, you could hack it in as follows (per line):

$atoz["items"][] = array("name" => "Artwork", "href" => "category/Artwork/' rel='nofollow");

(notice the missing ' from rel='nofollow - this is because it will be added in by atoz.php when generating what it thinks is just the href='' attribute...)

Cheers,
David.

Submitted by npaitken on Tue, 2009-02-10 19:03

Hi David,

Thanks for your reply.

Thinking about his a little more, I actually have quite a few pages, each full of links, to modify. So, perhaps it would be best to sort this once in atoz.php rather than have to troll through 10 or so hard coded pages.

What modification is required to atoz.php?

Many thanks,
Neil

Submitted by support on Tue, 2009-02-10 19:07

Hi Neil,

Sure - in html/atoz.php you will see this code on line 43:

print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";

..simply REPLACE this with:

print "<p><a rel='nofollow' href='".$item["href"]."'>".$item["name"]."</a></p>";

Cheers,
David.