Include <span> tags into quicktabs link

design.er - November 7, 2009 - 05:51
Project:Quick Tabs
Version:6.x-2.0-rc3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello,

I have to wrap the $tab['title'] within some tags. I guess I have to overwrite theme_quicktabs_tabs?
Here is what I did...

<?php
function phptemplate_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));
   
$options = _quicktabs_construct_link_options($quicktabs, $i);
   
$output .= '<li'. $attributes_li .'><a href="'. /* ??? */ .'"><span class="tab-left"></span><span class="tab">'. $tab['title'] .'</span><span class="tab-right"></span></a></li>';
   
$index++;
  }
 
$output .= '</ul>';
  return
$output;
}
?>

I don't know what to use as link and how to implement $options... the links are empty at the moment but nevertheless they work fine. Strange! :)))

Help is much appreciated.

Kind regards,
Stefan

#1

design.er - November 9, 2009 - 22:33

Hallo,

I found this snippet (from Theme templates):

<?php
function phptemplate_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));
   
$attributes_a = _quicktabs_construct_tab_attributes($quicktabs, $i);

   
$output .= '<li'. $attributes_li .'><span class="tab-left"></span><span class="tab"><a'. $attributes_a .'>'. $tab['title'] .'</span><span class="tab-right"></span></a></li>';
   
$index++;
  }
 
$output .= '</ul>';
  return
$output;
}
?>

It would work exactly the way I need it. The only problem is that _quicktabs_construct_tab_attributes($quicktabs, $i) seems not to be declared. I get a WSOD with the following error message:
Fatal error: Call to undefined function _quicktabs_construct_tab_attributes() in D:\DEVELOPMENT\xampp\www\mysite\sites\all\themes\mytheme\template.php on line 397

I see that this function was in earlier versions of QuickTabs but was dropped and is part of _quicktabs_construct_link_options(?).
Please can somebody help me with $attributes_a ?

If this is not possible this is my second possibility:

<?php
function phptemplate_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));
   
$options = _quicktabs_construct_link_options($quicktabs, $i);
//  $options .= array('html' => TRUE);
   
$output .= '<li'. $attributes_li .'>'. l('<span class="tab-left"></span><span class="tab">' .$tab['title'] .'</span><span class="tab-right"></span>', $_GET['q'], $options) .'</li>';
   
$index++;
  }
 
$output .= '</ul>';
  return
$output;
}
?>

The problem here is that it prints the <span> tags as plain text. If I try to extend the $options variable (with the commented line) to call it as html element I receive a WSOD with Fatal error: Unsupported operand types in D:\DEVELOPMENT\xampp\www\mysite\includes\common.inc on line 1582.

Please can somebody help me with the markup of one of this two snippets.

Help is much appreciated. Thank you very much.

Stefan

#2

Pasqualle - November 10, 2009 - 01:11

replace

<?php
    $options
= _quicktabs_construct_link_options($quicktabs, $i);
   
$output .= '<li'. $attributes_li .'>'. l($tab['title'], $_GET['q'], $options) .'</li>';
?>

with

<?php
    $options
= _quicktabs_construct_link_options($quicktabs, $i);
   
$options['html'] = TRUE;
   
$title = '<span class="tab-left"></span><span class="tab">' . $tab['title'] .'</span><span class="tab-right"></span>';
   
$output .= '<li'. $attributes_li .'>'. l($title, $_GET['q'], $options) .'</li>';
?>

#3

design.er - November 10, 2009 - 01:18
Status:active» fixed

Awesome, it works. Thank you very much, Pasqualle.

You rock! :)

#4

System Message - November 24, 2009 - 01:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.