adding nofollow attribute on drupal quicktabs

By dzieyzone

One of the main problem using a quicktab is that it duplicates your content and search engine will penalize you from that. So imagine if you use quicktabs most of your site, you won't notice that you are now on high risk being penalized. To make sure that the quicktabs links will not be followed by the robots is to add a rel=nofollow to the anchor tag and here is how you do it:

On your template.php file for your theme add the following code:

function <theme_name>_quicktabs_tabs($quicktabs, $active_tab = 'none') {
  $output = '';
  $tabs_count = count($quicktabs['tabs']);
  if ($tabs_count <= 0) {
    return $output;
  }

  $index = 1;
  $output .= '<ul class="quicktabs_tabs quicktabs-style-'. drupal_strtolower($quicktabs['style']) .'">';
  foreach ($quicktabs['tabs'] as $i => $tab) {
    $class = 'qtab-'. $i;
    // Add first, last and active classes to the list of tabs to help out themers.
    $class .= ($i == $active_tab ? ' active' : '');
    $class .= ($index == 1 ? ' first' : '');
    $class .= ($index == $tabs_count ? ' last': '');
    $attributes_li = drupal_attributes(array('class' => $class,'rel'=>'nofollow'));
    $options = _quicktabs_construct_link_options($quicktabs, $i);
		$options['attributes']['rel'] = 'nofollow';
    $output .= '<li'. $attributes_li .'>'. l($tab['title'], $_GET['q'], $options) .'</li>';
    $index++;
  }
  $output .= '</ul>';
  return $output;
}

Just change the <theme_name> with your theme name.

Your rating: None Average: 3 (1 vote)