Hi - first, love the module - exactly what I needed, thanks! :)

The one problem I'm having though is that I decided to create a separate template for the content type that uses the tabs. The name of this file is nod-plans-tpl.php. When I didn't find the print command easily to print the tabs I ended up hardcoding the unordered list menu inside this file. So now my code for the plans reads:

<div class="drupal-tabs">
	<ul id="planspg">
	<li><a href="#tabset-1">Floor Plans</a></li><li><li><a href="#tabset-2">Model A</a></li><li><a href="#tabset-3">Model B</a></li><li><a href="#tabset-4">Model C</a></li><li><a href="#tabset-5">Model D</a></li></ul>

Though the page works perfectly and I like that I was able to give the list their own id for customizing the look I now notice that I lost the ability to disable tabs if their is no content in that section. If you look at the list items in the code above you'll notice that I have tabs for Models A through D. The content in these sections only contain one image.

I guess my question is what is the correct code to include the tabs in a tpl.php page so that the tabs without content disappear? Or is there an if statement that I can include in the li tag that would give a class of "tabs-disabled" if the image for the each model doesn't exist?

So far I've tried the following code but unfortunately it either gives me a parse error, disables the tab even when the corresponding content DOES exist or it does nothing.

<li class="<?php if (content_format('field_model_a_img', $field_model_a_img[0]) == '0') { echo "tabs-disabled"; }else{ echo "none"; } ?>"><a href="#tabset-2">Model A</a></li>

Any help on this is appreciated! Thanks!

Comments

eggthing’s picture

Yes, I second this request. Would love to be able to use a node.tpl.php to customise bio and use cck fieldgroup tabs too.

eggthing’s picture

Any news on this?

mattez’s picture

+1

daniel wentsch’s picture

+1 subscribing
Unfortunately, without being able to output tabs in custom node template, I can't use them.

kolier’s picture

+1

And I think you can check whether the element in the group is empty();

codevelopment’s picture

+1

I'm looking for the same code -- it should really be documented somewhere, it's a pretty essential part of making tabs work on custom node templates.

Prasad Shir’s picture

Version: 5.x-1.x-dev » 6.x-1.2

I have same question / requirement. I need to make custom layout for a node type for which I am using CCK Field Group tabs. I tried using contemplate, node-type.tpl.php and even panels 3. For any of these options unable for find out what code or option to use to render CCK Fieldgroup tabs. Any help or pointer to a solution will be highly appreciated.

Prasad

hey_germano’s picture

+1, subscribing

I'd like to render a specific type of node's comment form on a tab, so I'm looking for a way to put this - <?php print comment_render($node, NULL); ?> - in a tab I create on the tpl.php. I think. But yep, having a little more control over these would be super awesome.

ahimsauzi’s picture

This is the code I use but for some reason I can't seem to make the empty tabs go away. Any suggestions?

 <div id="tabs-tabset" class="drupal-tabs tabs">
     <ul class="clear-block ui-tabs-nav tabs tabs primary">
     	<li><a href="#tabs-1-1">Tab 1</a></li>
         <li><a href="#tabs-1-2">Tab 2</a></li>
              <li><a  href="#tabs-1-3">Tab 3</a></li>
           </ul> 
<div id="tabs-1-1" class="fragment">
            <?php foreach ((array)$node->field_name as $item) { ?>
            <div class="field-item">
            <?php print $item['value'] ?></div>
            <?php } ?>
   </div>
  <div id="tabs-1-2" class="fragment">
              <?php foreach ((array)$node->field_name as $item) { ?>
            <div class="field-item"><?php print $item['value'] ?></div>
            <?php } ?>
    </div>
    <div id="tabs-1-3" class="fragment">
              <?php foreach ((array)$node->field_name as $item) { ?>
            <div class="field-item"><?php print $item['value'] ?></div>
            <?php } ?>
      </div>
</div>
ahimsauzi’s picture

I figured a solution. Add if statement between list elements. Like so:

<?php if(!empty($node->field_name[0]['value'])): ?>
     	<?php echo '<li><a id="someBtn" href="#tabs-1-1">Tab 1</a></li>'; ?>
     	<?php endif; ?>
miphol’s picture

How about this?

<?php print theme_tabset($node->content['fieldgroup_tabs']); ?>

Then you just implement theme_tabset() and theme_tabpage() to further customize the output.

ahimsauzi’s picture

That worked very well, thanks miphol!

I must say I was having hard time theming the output of that call. What will be the best way to override the output?
I can't find the theme_tabset() function...

amirtaiar’s picture

I am trying this code on a drupal 7 node-13.tpl.php I have created and the tabs are link to nothing.
I want them to link to a cck fields, rendering on a new #page.

So I have tried to add:

  <div id="tabs-1-2" class="fragment">
              <?php foreach ((array)$node->field_name as $item) { ?>
            <div class="field-item">
	    <?php print render($content['field_few_worrds']); ?>
	    </div>
            <?php } ?>
    </div>

But it doen't seems to work for me.
Any idea?

ravi shankar karnati’s picture

print theme_tabset($node->content['fieldgroup_tabs']);

this line works fine for me for include the tabs in node tpl, Great , wonderful, Thanks a lot....but only problem is when ever i put this code in node tpl file Print option is not working fine,,
plz check the below link

http://196.12.61.134:8888/connellfoley/print/92

it shows like that, no tabs and no print option pop up..

plz help me

Thanks in advance...