1

I've programmatically created some quicktabs in Drupal 7, however I require html tags within the title.

For e.g:

    $tabs_project['backers'] = array(
        'title' => t('Backers').'strong'.$backers_total.'strong',
        'contents' => 'backer information..',
        'weight' => 2,      
    );      

But this prints out the strong tags too.. Any ideas? (couldn't work out how to put the correct html tags in the pre tags, so left it as 'strong')

Cheers in advance,

1

Turns out you can apply something like so:

$qt_project['content']['content']['tabs']['tablinks']['backers']['#options']['html'] = TRUE;

thanks to comment on drupal forum

cheers

| improve this answer | |
0

A solution that avoids patching the module would be to override the appropriate theme function that outputs the "tabset" tab titles. For the quicktab style, a solution would look like this:

/**
 * Overrides Theme function to output tablinks for classic Quicktabs style tabs.
 */
function YOUR_THEME_NAME_qt_quicktabs_tabset($vars) {
  $variables = array(
    'attributes' => array(
      'class' => 'quicktabs-tabs quicktabs-style-' . $vars['tabset']['#options']['style'],
    ),
    'items' => array(),
  );
  foreach (element_children($vars['tabset']['tablinks']) as $key) {
    $item = array();
    if (is_array($vars['tabset']['tablinks'][$key])) {
      $tab = $vars['tabset']['tablinks'][$key];
      $tab['#options']['html'] = TRUE; // Added this to override to allow HTML in titles.
      if ($key == $vars['tabset']['#options']['active']) {
        $item['class'] = array('active');
      }
      $item['data'] = drupal_render($tab);
      $variables['items'][] = $item;
    }
  }
  return theme('item_list', $variables);
}

See the Quicktabs.module theme functions for reference here: http://drupalcode.org/project/quicktabs.git/blob/refs/heads/7.x-3.x:/quicktabs.module#l591

I crossposted this in this comment on d.o: https://drupal.org/comment/8343639#comment-8343639

| improve this answer | |
0

You can implement a "process" function for the qt_quicktabs_tabset theme-hook in your custom module like this:

function MYMODULE_process_qt_quicktabs_tabset(&$vars) {
  // Allow HTML in quicktab titles.
  foreach (element_children($vars['tabset']['tablinks']) as $key) {
    if (is_array($vars['tabset']['tablinks'][$key])) {
      $vars['tabset']['tablinks'][$key]['#options']['html'] = TRUE;
    }
  }
}
| improve this answer | |

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.