0

I'm writing below code in my node--type.tpl.php, but only empty page is loading when i load the node page.Can you please help in knowing my mistake. What i need to add to display quicktab and its corresponding viewmode content? my code is:

<?php
 $nid=$node->nid;

$tabs['Home'] = array(
  'title' => t('Home'),
  'type' => 'node',
  'nid' => $nid,
  'viewmode_home' => TRUE,
  'hide_title' => FALSE,
);
$tabs['About'] = array(
  'title' => t('About'),
  'type' => 'node',
  'nid' => $nid,
  'viewmode_about' => TRUE,
  'hide_title' => FALSE,
);


$quicktabs['qtid'] = 111; //given a random number
$quicktabs['tabs'] = $tabs;
$quicktabs['style'] = 'Mac';
$quicktabs['ajax'] = FALSE;
print theme('quicktabs', $quicktabs);
?>
0

I got this to work using node--typename.tpl.php

$tabs = array(
      array(
        'title' => t('Overview'),
        'type' => 'view',
        'vid' => 'product_tabs',
        'display' => 'block_1',
        'args' => $node->nid,
        'weight' => 0,
      ),
      array(
        'title' => t('Dimensions & Weight'),
        'type' => 'view',
        'vid' => 'product_tabs',
        'display' => 'block_4',
        'args' => $node->nid,
        'weight' => 1,
      ),
      array(
        'title' => t('Shipping'),
        'type' => 'view',
        'vid' => 'ps3_games',
        'display' => 'default',
        'args' => $node->nid,
        'weight' => 2,
      ),
      array(
        'title' => t('Ratings & Reviews (' . $node->comment_count . ')' ),
        'type' => 'view',
        'vid' => 'product_tabs',
        'display' => 'block_3',
        'args' => $node->nid,
        'weight' => 3,
      ),
    );
    $qtoptions = array(
      'style' => 'Zen',
      'ajax' => FALSE,
    );
    $qtname = 'commerce_product23';
    $quicktabs = quicktabs_build_quicktabs($qtname,$qtoptions,$tabs);
    print drupal_render($quicktabs['content']);

works with views, but if I try to use nodes it does not.

You should try another method.

Create a Quicktab using the Quicktabs UI. Then create a custom module to override the settings/output of the quicktab using the machine name to target a specific quicktab

For Example:

 function mymodule_quicktabs_alter($quicktabs) { 
    $nid = $node->nid
        if ($quicktabs->machine_name == 'quick_tab_front_page') { 
        $quicktabs->tabs = array(
          0 => array(
        'nid' => $nid,
        'view_mode' => 'full',
        'hide_title' => 1,
        'title' => 'Full',
        'weight' => '-99',
        'type' => 'node',
          ),
          1 => array(
        'nid' => $nid,
        'view_mode' => 'teaser',
        'hide_title' => 1,
        'title' => 'Teaser',
        'weight' => '-99',
        'type' => 'node',
          ),
        );
        $quicktabs->renderer = 'quicktabs';
        $quicktabs->style = 'Arrows';
        $quicktabs->options = array();
        }
        }
  • i tried this code in node--type.tpl.php file ,and adding only quicktabs of type node. //Node $custom_tabs[] = array( 'nid' => 1, 'view_mode' => 'full', 'hide_title' => 1, 'title' => 'Tab with a node' 'weight' => -98, 'type' => 'node', ); The problem is if i add 'nid' =>node_no of type corresponding node_type,then node page itself is not loading. – rks Feb 4 '16 at 6:19
  • 'nid' =>node_no of type corresponding node_type huh? what are you trying to do here? what do you want as nid? – No Sssweat Feb 4 '16 at 6:43
  • i declared $nid=$node->nid; in my node--type.tpl.php file and 'nid' =>$nid – rks Feb 4 '16 at 6:55
  • i want quicktabs for a node with different view_modes – rks Feb 4 '16 at 6:58
  • then use for example 'view_mode' => 'teaser', – No Sssweat Feb 4 '16 at 7:14

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.