Title is self explanatory. Is that possible? For example the Navigation Block shows the Users name.

Thank you!

Comments

Pasqualle’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Category: support » feature

I think we can make a new feature to use tab content title (node title, block title, view title) as tabpage title. does it sound useful?

Pasqualle’s picture

Title: Dynamic labels for QT blocks and their tabs? » Dynamic title for tabs
Version: 6.x-2.x-dev » 6.x-3.x-dev

Moving new features to 3.x version

daniorama’s picture

I just downloaded the new version. I will play with it and see the new features (the ajax feature works really nice!)

benklocek’s picture

Very useful feature, especially for translations of the content.

ManyNancy’s picture

@#3 is this already implemented?

Pasqualle’s picture

dynamic title for tabs is not implemented yet

askit’s picture

QuickTab is great, and it will be perfect if dynamic title feature is added!

jrabeemer’s picture

+1^99 for this feature.

Otherwise the title is static and often not relevant to the content within the tab. :-(

Thinking about it some more, I think it would be possible to do a theme_preprocess_block() function to edit the output HTML and modify the text of a tab.

You could even do it with jQuery post load.

Either way, it's a hack.

flaviovs’s picture

Wouldn't be better if we can use tokens on the title of each tab?

So if you tab has a node in it, you set its title to "[node:title]" and voilá tab title is now the node title?

I thinks that this makes the module much more flexible than if we have only a "use inner content title" on/off option.

pheraph’s picture

Subscribing

BeaPower’s picture

is this possible now?

design.er’s picture

I think, the suggestion of comment #9 is the Drupal way. It would open all the needed possibilities of dynamic content and only use the tokens the user really need - of the installed modules that provides tokens.

molave’s picture

Using tokens would be a great idea, I think, and very flexible, and it would be implemented in a manner that current token users already understand.

glitz’s picture

subscribe

g76’s picture

+1 for D7 as well.

rv0’s picture

+1

any programmatical workaround available for now?

katbailey’s picture

If you are happy to build the quicktabs programmatically then you can definitely achieve this. You can either use hook_quicktabs_alter to alter an existing quicktabs instance in any way you want (in this case changing the titles to something programmatically driven); or you can build the quicktabs from scratch using quicktabs_build_quicktabs() - see the README file for details.

To add this to the UI, someone would need to write a renderer plugin that extends the Quicktabs renderer plugin and adds the token handling.

rv0’s picture

@katbailey
thanks, I used the hook_quicktabs_alter solution and it's working fine :)
Had a hard time finding info about it ;)

katbailey’s picture

@rv0, well you know what to do then, don't you? ;-) Provide documentation somewhere that others can find - a patch for the readme file would be great. I have 4 branches of this module to maintain, I really appreciate patches ;-)

Oh and the stuff I said above re renderer plugins of course only applies to the 7.x-3.x branch.

BeaPower’s picture

yes @rv0 please tell us what you did, thanks.

rv0’s picture

BeaPower - there's not really much to it, write a function yourmodule_quicktabs_alter($arg)
dpm() the $arg to see what you can do with it, and act accordingly.
if i knew more about this hook i could write some docs about it, but now i just tried with trial and error until it worked.

BeaPower’s picture

Where do you write this? I'm still new to drupal.

rv0’s picture

BeaPower - Look up how to write your own module: http://drupal.org/developing/modules
Install devel so you can use the dpm() function to display contents of objects/arrays/...

caponey’s picture

I am using Quick Tabs to display search results. It would be cool to dynamically insert the number of results in the title, i.e., Games (3) | Reviews (5) | Articles (20), etc...

BeaPower’s picture

SAme here, this is actually what I wanted to try and do. How do you do this?

BeaPower’s picture

any updates?

khoomy’s picture

I display block title as tab title by overriding theme function as:

function THEMENAME_quicktabs_tabs($vars) {
  $output = '<ul class="quicktabs_tabs quicktabs-style-' . $vars['tabset']['#options']['style'] . '">';
  foreach ($vars['tabset']['tablinks'] as $i => $tab) {
    if (is_array($tab)) {
      $tab_id = array_keys($tab['#options']['query']);
      $bid = $tab['#options']['query'][$tab_id[0]];
      $tab_id = str_ireplace('quicktabs_', '', $tab_id[0]);
      $qt = quicktabs_load($tab_id);
      if ($qt->tabs[$bid]['type'] == 'block') {
        $delta = str_ireplace('block_delta_', '', $qt->tabs[$bid]['bid']);
        $block = block_load('block', $delta);
        if ($block->title) {
          $tab['#title'] = $block->title;
        }
      }
      $active = $i == $vars['tabset']['#options']['active'] ? ' class="active"' : '';
      $output .= '<li' . $active . '>' . drupal_render($tab) . '</li>';
    }
  }
  $output .= '</ul>';
  return $output;
}
<

You can change it for views also.

I hope this will help someone :) cheers

hefterbrumi’s picture

Version: 6.x-3.x-dev » 7.x-3.4

HI!

Could somebody point me towards the right direction on this?
I have a several products, each has a quicktab connected to it (4 tabs, each tab has a view with slideshow). I created 4 textfields to this content type, and I would like to alter the title of the tab titles according to the textfields.

I found a reply http://drupal.org/node/303453#comment-5631104. I would prefer using hook_quicktabs_alter but dont really know how to begin.

Please help.

rv0’s picture

@hefterbrumi

Install devel,
Look up how to make a module.
in the module add this

function yourmodulename_quicktabs_alter(&$quicktabs) {
 dpm($quicktabs);
}

look at the result..
& change the value of $quicktabs array to your taste.

hefterbrumi’s picture

I'll give it a try thanks...

hefterbrumi’s picture

Ok I have found the titles:

$...->tabs[0]['title']
$...->tabs[1]['title']
$...->tabs[2]['title']
$...->tabs[3]['title']

I am not really into coding but I need to solve this so the php will be something like:

<?php
function yourmodulename_quicktabs_alter(&$quicktabs) {
$tabs[0]['title'] = $form['titletext0']
$tabs[1]['title'] = $form['titletext1']
$tabs[2]['title'] = $form['titletext2']
$tabs[3]['title'] = $form['titletext3']
}
?>

Is that correct?
Also I cant find the variables storing the title text so the ones in the code are just guesses. For some reason I cant find them with devel.

I used :

<?php
	 dpm( get_defined_vars() );
?>
rv0’s picture

No reason to use get_defined_vars.. just dpm($quicktabs) as that is the (only) argument provided in the function

I don't know what you mean with $form['titletext0'] .. there is no variable $form.. you'll need to write a helper function that gets the strings you need or hardcode it.

hefterbrumi’s picture

I see. I used get_defined_vars becaouse I thought I can get the strings this way. Hardcoding it is not a solution since its changing according to a textfield that the uploader fills out when creating a new "product".

But how do I get the strings?

Maybe field_get_items


if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1); //getting nid

function getTitles(){
$title1 = field_get_items('node', $nodeid, 'titlefield1');
$title2 = field_get_items('node', $nodeid, 'titlefield2');
$title3 = field_get_items('node', $nodeid, 'titlefield3');
$title4 = field_get_items('node', $nodeid, 'titlefield4');
}

function yourmodulename_quicktabs_alter(&$quicktabs) {
$tabs[0]['title'] = $title1;
$tabs[1]['title'] = $title2;
$tabs[2]['title'] = $title3;
$tabs[3]['title'] = $title4;
}

Sorry for being stupid but I dont have experience in this....

rv0’s picture

there's more to it.
- field_get_items takes a node object, not a nid.. so node_load(arg(1));
- $tabs does not exist.. use the $quicktabs variable

Learn how arrays and objects work. use devel to know what functions return.

I guess learning you how to code is also outside the scope of this issue

hefterbrumi’s picture

Thank you for the directions. Meanwhile I found a module called Field data extraction, I'll look into it.

Would you learn farming for one carrot :) ?

hefterbrumi’s picture

I finally solved my issue. I used quicktabs_build_quicktabs to create a new quicktab programatically and used tokens to get the values of the title field.

I used display suite to create a code field where I put the code. That I attached it to my content type.

<?php
    $tabs = array(
      array(
        'title' => '[node:field_extra_field_1_title]',
        'type' => 'view',
        'vid' => 'extra_field_1',
        'display' => 'block',
        'args' => 	'',
        'weight' => 0,
      ),
      array(
        'title' => '[node:field_extra_field_2_title]',
        'type' => 'view',
        'vid' => 'extra_field_2',
        'display' => 'block',
        'args' => 	'',
        'weight' => 1,
      ),
      array(
        'title' => '[node:field_extra_field_3_title]',
        'type' => 'view',
        'vid' => 'extra_field_3',
        'display' => 'block',
        'args' => 	'',
        'weight' => 2,
      ),
      array(
        'title' => '[node:field_extra_field_4_title]',
        'type' => 'view',
        'vid' => 'extra_field_4',
        'display' => 'block',
        'args' => 	'',
        'weight' => 3,
      ),
    );
    $qtoptions = array(
      'style' => 'Basic',
      'ajax' => FALSE,
      'hide_empty_tabs' => TRUE,
    );
    $qtname = 'commerce_product';
    $quicktabs = quicktabs_build_quicktabs($qtname,$qtoptions,$tabs);
    print drupal_render($quicktabs['content']);
?>
snaushads’s picture

Subscribing. Cant do it programmatically atm.

ultimateboy’s picture

Title: Dynamic title for tabs » Token Support for Quicktab Tab Titles
Version: 7.x-3.4 » 7.x-3.x-dev

I'm interested in pursuing this, it's trivial to add site token support to the fields, but it's more difficult to add node tokens (for things like [node:author] in a tab title for example). Overall, I think it might be easier to first #2090657: Make quicktabs entity-aware and then handle tokens uniformly across all entities.

PhilY’s picture

Issue summary: View changes

An old issue but here is how I solved it in a custom module:

/**Implements hook_quicktabs_alter().
 * Have quicktab title follow node title (for node based tabs)
 */
function YOURMODULE_quicktabs_alter(&$quicktabs) {
  foreach ($quicktabs->tabs as $tabIndex => $tabContent) { // for each quicktabs tab...
    if ($tabContent['type'] === 'node' ) { // ... where tab is node based
      $node = node_load($tabContent['nid']); // load associated node
      $quicktabs->tabs[$tabIndex]['title'] = $node->title; // set node title as tab title
    } // end if
  } // end foreach
}
l.medves’s picture

Hi,

Thank you for the great module, saved me a ton of time!

I am using the D8 version of the module and cannot find any way of dynamically changing the tab titles. I cannot find the above mentioned hook or theme function. Do you have any other ideas / suggestions?