How to make a tab to act like a link which redirect user to the specified page when clicked instead of opening tab content?

Comments

EkaMei’s picture

That request seem to defeat the purpose of quick tab entirely, if they become a link when clicking, why not just use a dynamic link module instead?

bsod’s picture

Because I need to change only one tab in quicktab block into dynamic link, so it will look like this:

__|tab1(latest articles)|__|tab2(popular articles)|__|tab3(link to node/add/article)|__

pasqualle’s picture

Status: Active » Postponed (maintainer needs more info)

@bsod: As I understand you want some tabs to work as tabs, and some as page links. Can you give a specific example how would you use that feature? If you put the page links into the tab content that would not be as useful?

pasqualle’s picture

Status: Postponed (maintainer needs more info) » Active

ok, I crossposted. The example is good

pasqualle’s picture

I think such feature directly supported by the module is outside of its functionality.

You can override the theme_quicktabs_tabs() theme function to add any other link to it. I would like to see some theme template files for quicktabs to make such changes easier in the future..

bsod’s picture

Thanks, I will try this solution.

It would be nice if user can also put qt block title or any plain text before tabs, in the same line, so it will look like this:

__Articles:__|tab1(latest articles)|__|tab2(popular articles)|__|tab3(link to node/add/article)|__

pasqualle’s picture

Title: Tab title as link » Theme templates
Category: support » feature

Yes, that also can be done with theming.

I change this to feature request as there is no QT issue about theme templates and make theming easier..

bsod’s picture

As my knowledge about theming via theme functions is poor I'll be very thankful if you could give me more specific example how such theme function should look.

pasqualle’s picture

In the theme template.php file you can create a MyThemeName_quicktabs_tabs() function where you copy the code from theme_quicktabs_tabs() and change it as you like.

This code should work with garland (but I did not tested), and it contains your required changes with a "+" sign at the line start (you need to delete the + sign). Also this will change all quicktabs, so you will may have to use some "if" statements where required.

function garland_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']) .'">';
+  $output .= '<li>'. $quicktabs['title'] .'</li>';
  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));
    $attributes_a = _quicktabs_construct_tab_attributes($quicktabs, $i);

    $output .= '<li'. $attributes_li .'><a'. $attributes_a .'>'. $tab['title'] .'</a></li>';
    $index++;
  }
+  $output .= '<li>'. l('Create article', 'node/add/article') .'</li>';
  $output .= '</ul>';
  return $output;
}
EkaMei’s picture

This would probably be best suitable for an addition option in adding quick tap, beside adding a block, node, and another QT, it should have an additional choice to add a simple link to the tab itself.

At first I was a little skeptical, but this is indeed a very good feature suggestion!

bsod’s picture

@Pasqualle, everything works great except link tab which works like a qtab not like a link.

pasqualle’s picture

@bsod: you are right. Every link inside <li> is turned into qtab link because of the javascript in QT. If you change it to

$output .= '<div>'. l('Create article', 'node/add/article') .'</div>';

then it works as a link, but it results in invalid HTML..

Maybe some modifications will be needed in the js also, to support good QT templates.

@EkaMei: I am not convinced that QT should support "quick tap". That would require serious rethink of the QT source code, because all other types change the tab content, not the tab link. With theme template files more extreme ideas can be achieved easily..

EkaMei’s picture

That is true, I can see few scenario where this will work well, but it might not be worth the hassle

pasqualle’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev

Moving new features to 3.x version

brianmercer’s picture

Has anyone created a quicktabs.tpl.php?

I just want to add "clear-block" to the classes for quicktabs_wrapper, quicktabs_tabs and quicktabs_main. Has anyone converted quicktabs_render to a preprocess and tpl.php?

pasqualle’s picture

@brianmercer: no, there is no theme template file support in QT yet.

jenlampton’s picture

Title: Theme templates » Theme functions or template files

It would also be great if the markup from quicktabs_render could be moved into a theme function, or template file.

I needed to add a clearfix in order to make the "basic" tab style work with a grid-style table view, and had to patch edit the .module file to get that to happen. :(

(For those of you curious how to make this happen, it's line 245, prepend a clearing div before the two closing div tags, like so:)

  $output .= '<div class="clear-block"></div></div></div>';
netw3rker’s picture

Issue summary: View changes
Status: Active » Closed (fixed)