I have been trying to work something out for the past few days, and I am beginning to think that my use of contemplate might be whats tripping me up. I have a functioning body template for one of my content types which works great. I have coded in a set of tabs which show a field or group as a tab this works great, however for one of my tabs I require a more stylized layout. I've been banging my head trying to figure the best way to accomplish this.

Currently, I have a function in my template.php file which calls up my html markup with several field hooks contained in it. I know my function is working 'sort-of' because a text string and the divs are showing up in my rendered tab(verified with firebug). The problem is that the field hooks are not rendered. Is there some reason that the hooks wont render when being passed from a variable; or is it just my syntax? (see below)

Is there a better way to handle this than using an external function? I thought maybe a block would be nice or a page ... however the page produces the same error... none of the field hooks are rendered; and I couldn't even add a region as a tab to get the block to work.

I was also thinking this may be an issue related to the jQuery tabs which come with jstools module and the way in which tabs are called to the page using the forms api. I have created an issue in the tabs module folks but no responses have come. I'm not really sure if the problem is there but I could be so I tried there first.

Below is my tabs code; Which I place in my body template for this content type I trimmed everything out but the tabs stuff, as the rest works great.

<div id="prop_tabs">
<?php
            $tab_A = pointsGrid();
           
            $form = array();
              $form['example1'] = array(
                '#type' => 'tabset',
              );
              $form['example1']['tab1'] = array(
                '#type' => 'tabpage',
                '#title' => t('Overview'),
                '#content' => $node->field_prop_overview[0]['view'],
                '#weight' => '-8',
              );
              $form['example1']['tab2'] = array(
                '#type' => 'tabpage',
                '#title' => t('Onsite Amenities'),
                '#content' => $node->field_onsite_amenities[0]['view'],
                '#weight' => '-7',
              );
              $form['example1']['tab4'] = array(
                '#type' => 'tabpage',
                '#title' => t('Points Grid'),
                '#content' => $tab_A,  
                '#weight' => '-5',
              );
              $form['example1']['tab5'] = array(
                '#type' => 'tabpage',
                '#title' => t('More Details'),
                '#content' => $node->content['group_more_information']['#children'],
                '#weight' => '-4',
              );
              return tabs_render($form);
              ?>

</div>

Below is the function which I added to my template.php in order to produce the desired markup with various hooks within it. This is just a small example as my real need for this is about 25 fields nested in a table with several divs with external css styling.

function pointsGrid() {
       $output .= t('I am here');
       $output .= ' <div id="mydiv2">'. $node->field_city[0]['view'] ."</div>\n";
       $output .= ' <div id="mydiv3">'. $node->field_state_region[0]['view'] ."</div>\n";
       $output .= ' <div id="mydiv4">'. $node->field_country[0]['view'] ."</div>\n";
       return $output;
}

Comments

Macronomicus’s picture

Title: Problem with hooks in tabs » Solved found better tabs script.
Status: Active » Fixed

Solved: found better tabs script.... There is no need to use the $form method for what I am doing it was only complicating things.

	<div id="tabs-1" class="drupal-tabs">
		<ul class="anchors">
			<li><a href="#tabs-1-1">About <?php print check_plain($node->title) ?></a></li>
			<li><a href="#tabs-1-2">Bio</a></li>
		</ul>
		<div id="tabs-1-1" class="fragment">
			<h2 class="drupal-tabs-title" >About <?php print check_plain($node->title) ?></h2>
			<?php foreach ((array)$node->field_some_image as $item) { ?>
			<div class="field-item"><?php print $item['view'] ?></div>
			<?php } ?>
			<?php print $node->content['body']['#value'] ?>
		</div>
		<div id="tabs-1-2" class="fragment">
			<h2 class="drupal-tabs-title" >Bio</h2>
			<?php print $node->content['field_bio_text']['#value'] ?>
		</div>
	</div>
Anonymous’s picture

Status: Fixed » Closed (fixed)

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