Using Tabs on Content Page with CCK fields the easiest way

I've been struggling on adding tabs in showing my CCK fields. Here's my easiest and quickest guide of showing your CCK fields in a TAB

Here's a example of my code assuming that I have a fields details and labels in an array format:
field_detail_1
field_detail_2
field_detail_3
field_label_1
field_label_2
field_label_3


<?php
for ($count=1;$count<=2;$count++):
$field = 'field_detail_'.$count;
$tablabel = 'field_label_'.$count;
$ptab = $node->$field;
$plabel = $node->$tablabel;
if (!empty($plabel[0]['value'])):
$tabs['tab'.$count] = array(
'title' => t($plabel[0]['value']),
'type' => 'freetext',
'text' => check_markup($ptab[0]['value']),
);
endif;
endfor;
$quicktabs['qtid'] = '101';
$quicktabs['tabs'] = $tabs;
$quicktabs['style'] = 'Basic';
$quicktabs['ajax'] = FALSE;
echo theme('quicktabs', $quicktabs);
?>

Your rating: None Average: 5 (1 vote)