Discussions

Quicktabs module

hie

Hie i would like to display information in the detail product with tabs

using Quicktabs module

i try with panel whitout success

my be the solution is to create field text in the product display and adding a Quick Tab block to this this text as this link describe
https://drupal.org/node/679148

thanks to your help

Posted: Nov 25, 2013

Comments

CptAnt on November 28, 2013

I've done this by creating a module which supplied the quicktabs as a block. Here some sample code.

[code]
/**
* implements hook_block_info
* @return creates a block
*/

function product_info_tabs_block_info() {
// This example comes from node.module.
$blocks['product_info_tabs'] = array(
'info' => t('Product info tabs'),
'cache' => DRUPAL_NO_CACHE,
);

return $blocks;
}

/**
* Implements hook_block_configure().
*/
function product_info_tabs_block_configure($delta='') {
$form = array();

switch($delta) {
case 'product_info_tabs' :
// Text field form element
$form['text_body'] = array(
'#type' => 'text_format',
'#title' => t('Enter your text here in WYSIWYG format'),
'#default_value' => variable_get('text_variable', ''),
);

break;
}
return $form;
}

/**
* Implements hook_block_save().
*/
function product_info_tabs_block_save($delta = '', $edit = array()) {
switch($delta) {
case 'product_info_tabs' :
// Saving the WYSIWYG text
variable_set('text_variable', $edit['text_body']['value']);

break;
}
}

/**
* Implements hook_block_view().
*/
function product_info_tabs_block_view($delta='') {
$block = array();

switch($delta) {
case 'product_info_tabs' :
$block['content'] = tab_block_view();
break;
}

return $block;
}

/**
* Custom function to assemble quicktabs for block content.
* Returns a renderable array with the block content.
* @return
* returns a renderable array of block content.
*/
function tab_block_view() {
// Load the current node
$node = node_load(arg(1));
if ($node) {
$nid = $node->nid;

//Get the node type
$product_types = array();
$product_types[] = $node->type;

//Create the block subject to the node type matching the conditions
if (in_array('metal_detector_display', $product_types)) {

$block = array();

// Capture WYSIWYG text from the variable
//$text = variable_get('text_variable', '');

// Create an array of tab content
$tab_content = array();

$tab_content[] = views_embed_view('product_description', 'block_product_description', $nid );
$tab_content[] = views_embed_view('product_specifications', 'block_product_specifications', $nid );

$block = add_quick_tab($tab_content);

return $block;
}
}
return;
}

/**
* @param $tab_content
* @return
*
* Returns the block of tabbed content
*/
function add_quick_tab($tab_content){

$tabs = array(

$tabs[] = array(
'title' => t('Description'),
'contents' => $tab_content[0],
'weight' => '0'
),
$tabs[] = array(
'title' => t('Specifications'),
'contents' => $tab_content[1],
'weight' => '1,'
),
/*$tabs[] = array(
'title' => t('Tab Three'),
'contents' => 'AJWA',
'weight' => '2',
),*/
);

// Configure the QuickTabs options
$quicktabs_options = array(
'style' => 'Sky',
'ajax' => FALSE,
);

$quicktabs_name = 'product_information';
$quicktabs = quicktabs_build_quicktabs($quicktabs_name, $quicktabs_options, $tabs);
return $quicktabs;
}
[/code]

this loads specific views but should get the idea from the code. It needs cleaning up!!

call the quicktab block from your product display template using

[code]
$product_tabs = module_invoke('product_info_tabs', 'block_view', 'product_info_tabs');
print render($product_tabs);
[/code]

The rende statement needs to call by reference so calling print render(module_invoke('product_info_tabs', 'block_view', 'product_info_tabs')); directly will generate a warning.

Hope this helps