Hi there,

I know that it´s possible, overriding theme_links function, but I don´t know where to add the rel=nofollow code in the function code:

http://api.drupal.org/api/function/theme_links/6

Anyone could help me please? Thanks in advance, Simon.

Comments

SimonVlc’s picture

Anyone?

yfreeman’s picture

Originally I thought that the $attribute argument should do it for you.

$attributes = array('class' => 'links', 'rel'='nofollow')

but that will just style the UL tag

after skimming the code it would seem that you can supply attributes to the $links array.

such as

$links = array();

// for each link you can supply attribute like this
$link = array();
$link["title"] = "title of the link";
$attributes = array();
$attributes["class"] = "class_link";
$attributes["onMouseOver"] = "javascript:run_code();";
$attributes["rel"] = "nofollow";


$link["attributes"] = $attributes;
$links[] = $links;

// pass the $links to the function

theme_links($links, $attributes = array('class' => 'links')) ;

since each links gets passed through l()


 if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .= l($link['title'], $link['href'], $link);
      }


you should be able to use it just like any other call to the l() function.

According to the docs the second argument will apply the attributes to the themed linkes. rel=nofollow is an attribute and should be applied.

Note: this is not tested, just off my head.

If the $links variable is generated somewhere else, you would have to cycle through the links and find the 'attribute' key, if it has one, and then manually add the attribute.

SimonVlc’s picture

Thanks a lot kaiserjozy ;)! That was!!!

Mike_Waters’s picture

Or,

$link = array(
   'href' => 'http://whatever',
   'title' => 'this is a title',
   'attributes' => array(
       'target' => '_blank',
       'rel' => 'nofollow',
   ),
);
$links[] = $link;