I mostly have this all working effectively however I'm missing a small piece of the puzzle; which is a little bit of the php syntax, as I am mildly skilled in php I am stuck on something I'm sure is simple.
Here is my scenario which is working beautifully up to about 99.9% save for the last point below.
Okay I am implementing CCK for a custom content of type (Resort). I have created a great form to enter a myriad of fields they all work fantastically....
I went one step further and created a template for this node type (with contemplate) which also works great I was able to place hooks for all the fields in the manner I liked with all my custom html/js/css and whatnot; it works great.
I have also created a tabs set in the template page which works great see code below. Heres the thing though my code only works when I place one hook in the '#content' => !!in here!!, All of my tabs setup that way work great but I need another of the tabs to be a little more complicated than the others. I need it to have some html/css structure containing many other hooks.
I thought about creating a region to add a block to just that tab but was unsuccessful. My guess is that I need to create a function call to fetch the content. I am used to a different way of doing tabs with mootools in which anything I placed between two tags would be rendered in the tabs. The tabs jquery module does not work that way, at least for me.
What is the correct way to structure the syntax here to render my tabs? The code below is a form array; is there a better way? If this is the best way how would I add a variable to the tabs structure that calls a separate set of markup? You can see in the code below on "tab4" I was able to implement something close using $tab_A to call a node where I tried to place my markup. The problem is that it simply shows a text output none of the hooks I placed are executed.
If anyone could help I would greatly appreciate it.
Below is my tabs code; Which I place in my body template for this content type I trimmed everything out but the tabs stuff.
//////
<div id="prop_tabs">
<?php
$node_1 = node_load(array('nid' => 22));
$tab_A = $node_1->body;
$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>
Comments
Reading the form api
Im reading the form and other api's at the drupal api there must be some answers in there.
Is there a way to add my custom code to the top part as a function like below? So then I just add the $tab_A variable to the '#content' => part in the tabs script and it adds and executes into the tab?
Im really not sure how to get that implemented but I will keep reading the api and other form/group posts nothings come up yet... I will post back here if I figure it out.
In the mean time anyone have any tips?
say, you want to pass the
$node->body would only return the content (body) of the node. It's the same content pulled from the database.
say, you want to pass the $output from $tab_A?
If you are gonna add it to the '#content' element:
instead, $tab_A can be a function, let's say myDivs():
Then, on your tabs script, you can assign
I don't know if this is what you were trying to achieve, but I hope this helps.
Thanks for the tip
Thanks for the tips man. It looks like it should work perfectly but its not rendering to the tab. I dont think the syntax is the problem at this point as what you gave me seems to be proper code, according to most of the docs ive read in the past few days.
I have added the function to my template.php page.
Then on my content type body template ive called the function inside the tabs script. Nothing comes up in that tab.
I was sure this would work ... is there something that I have glaringly wrong here?
My main goal is to use my body template (contemplate) for this content type to call the tabs, inserting the hooks to render fields. The problem is that in one of the tabs I need to fully customize the layout with about 20 separate fields. I have used tabs for eons and never run into a problem like this. This forms api method is killing me! lol.
Still digging
I placed a text string to test and see if my function is connecting properly; the text is showing in my tabs ... so I know the function is responding and everything is named right. Its just the way I have laid the other markup ... I think my syntax is off in the way they are contained in the $output .= lines. I am digging through the drupal api,but I think this is a php coding thing.
Time to hit up some php syntax tutes. Im so close I can taste it.... Yippy! ^_^
Just wanted to add that it is rendering the divs too but they are empty, I sniped this from firebug...