1

I have set up quicktabs programmatically - all working fine. Code is as follows:

    $tabs['overview'] = array(
        'title' => 'Title of tab',
        'contents' => $content,
        'weight' => 2,
    );

.. etc

    $qt_options = array(
        'style' => 'nostyle',
        'ajax' => FALSE,
        'default_tab'=> 'overview',
    );

    $qt_name = 'project-tabs';
    $qt_project = quicktabs_build_quicktabs($qt_name,$qt_options,$tabs_project);

Issue: I need to add a rel='nofollow' to the quicktabs. Are there any attributes option I can pass to the $tabs array? Similar to using the l() function? I've looked and tried a few things, but nothing seems to work.

  • It's just my curiosity, but why would you want nofollow on internal links? As far as I can find it should be avoided – Mołot Jul 24 '13 at 11:08
  • 2
    I'm gonna assume he is having issues with search engines crawling these links (See an issue about that here: 2bits.com/bing/… – Jimajamma Jul 24 '13 at 11:24
  • @Jimajamma if so, proper "canonical" tag and robots.txt settings should help it. I guess this issue is one of the trade-offs. Should tabs fail if js fails? Or should they not, at the cost of some additional non-# links? Quicktabs devs selected the second way. I wish first one would be an option, but at the moment it isn't. – Mołot Jul 24 '13 at 11:31
2

Unless you want or can modify $qt_project and add in the rel to the attributes array of the links, the only way I see is to add in a custom renderer in your module.

This would entail some ctools integration implementing hook_ctools_plugin_type(), some quicktabs integration implementing hook_quicktabs_renderers() and then basically copying QuickQuicktabs.inc from the quicktabs module to your module's directory structure, changing the name to something appropriate, and then inside, also changing the name of the QuickQuicktabs class to something similar, and then in the guts of that, changing

/**
 * Helper function to construct link options for tab links.
 */
protected function construct_link_options($tabkey) {
  $qt_name = $this->quickset->getName();
  $id = 'quicktabs-tab-' . implode('-', array($qt_name, $tabkey));

  // Need to construct the correct querystring for the tab links.
  $query = drupal_get_query_parameters(NULL, array("qt-$qt_name", 'q', 'page'));
  $query["qt-{$qt_name}"] = $tabkey;

  $link_options = array(
    'attributes' => array(
      'id' => $id,
    ),
    'query' => $query,
    'fragment' => 'qt-' . $qt_name,
  );
  return $link_options;
}

to most probably just

/**
 * Helper function to construct link options for tab links.
 */
protected function construct_link_options($tabkey) {
  $qt_name = $this->quickset->getName();
  $id = 'quicktabs-tab-' . implode('-', array($qt_name, $tabkey));

  // Need to construct the correct querystring for the tab links.
  $query = drupal_get_query_parameters(NULL, array("qt-$qt_name", 'q', 'page'));
  $query["qt-{$qt_name}"] = $tabkey;

  $link_options = array(
    'attributes' => array(
      'id' => $id,
      'rel' => 'nofollow',  // just this one little addition :)
    ),
    'query' => $query,
    'fragment' => 'qt-' . $qt_name,
  );
  return $link_options;
}

and then calling quicktabs_build_quicktabs() with 'render' pointing to your custom renderer in the $qt_options array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.