In the following book page i will theme a CCK content typ in 3 different ways. First I post the content typ: This should be a bill which could the sent to an client, therefore I have the following fields title field_client // A node reference to a content typ called client to get the adress data etc. field_seller // A user reference to a roll called seller, so that you can have a analyze of your workers field_bill_text // A text to the client which is added to the bill field_pay_date // A Date on which the client has to pay, this could be f.e. used for views field_a_nr // A node reference to a content typ called article to get the description, the price per article field_a_count // How many articles, on aboves type was salled; perhaps you could add a functionality whether there are some articles, which are availible field_bill_me // ME = Mailing exchanges, how many should be added to the price This fields are supplemented with a lot of computed fields , f.e. one for getting the price per article field_a_nr); $i ++) { $article = node_load($node->field_a_nr[$i]['nid']); $node_field[$i]['value'] = $article->field_price[0]['value']; } ?> or for summand all articles to an end price field_r_articleprice); $i ++) { if (is_numeric($node->field_r_articleprice[$i-1]['value'])) { if (is_numeric($node->field_a_count[$i-1]['value'])) { $node_field[$i-1]['value'] = $node->field_r_articleprice[$i-1]['value']*$node->field_a_count[$i-1]['value']; } } } ?> So the user doesn't have to calculate any more. Steps: 1. Creation of Themes The first theme was a basic try to use theming form, f.e. how can fields be displayed in a table Bildschirmphoto32.jpg Choose the Articles
'; // The main Table; for each article a field for the article and on for the count for($i=0; $i < $count; $i++) { if ($i % 2 == 1) { $var = 'even'; } else { $var = 'odd'; } $output .= ''; $output .= ''; $output .= '
Articel Count
'. drupal_render($form['group_bill']['field_a_nr'][$i]). ''. drupal_render($form['group_bill']['field_a_count'][$i]) . ' The second theme displays the form as Tabs with JSTabs in JSTools Bildschirmphoto33.jpg '; $output .= ' General '. drupal_render($form['field_client']); $output .= ''; $output .= '
'; $output .= drupal_render($form['field_seller']); $output .= '
'; $output .= '
'; $output .= drupal_render($form['field_pay_date']); $output .= '
'; // An extra variable for better integration into JSTABS $content['general'] = $output; // Print a table with fields for the Nodereference A_NR to an Artical and the count of this articles // How many Articles? $count = count(element_children($form['group_bill']['field_a_nr'])); // $Output as a tmp variable // first the head of an table $output = '
Choose the Articles
'; // The main Table; for each article a field for the article and on for the count for($i=0; $i < $count; $i++) { if ($i % 2 == 1) { $var = 'even'; } else { $var = 'odd'; } $output .= ''; $output .= ''; $output .= '
Articel Count
'. drupal_render($form['group_bill']['field_a_nr'][$i]). ''. drupal_render($form['group_bill']['field_a_count'][$i]) . ' 'tabset', ); $formtab['tabblock1']['tab1'] = array( '#type' => 'tabpage', '#title' => t('General'), '#content' => $content['general'], '#weight' => -10, ); $formtab['tabblock1']['tab2'] = array( '#type' => 'tabpage', '#title' => t('Bill'), '#content' => $content['bill'], '#weight' => -2 , ); $formtab['tabblock1']['tab3'] = array( '#type' => 'tabpage', '#title' => t('text'), '#content' => $content['text'], ); // render the tabs echo tabs_render($formtab); echo drupal_render($form['form_token']); echo drupal_render($form['form_id']); echo drupal_render($form['options']); echo drupal_render($form['preview']); echo drupal_render($form('submit']); ?> The third theme displays the form like the standard way but with a css class .item. This class is used by jquery to hide, first each element, and than show the next form by clicking the next link or the key [page down] First you have nothing Bildschirmphoto34.jpg Than after 3 [Page downs] Bildschirmphoto35.jpg 3.bill-edit.tpl.php: '. drupal_render($form['title']) .''; echo '
'. drupal_render($form['field_client']) .'
'; echo '
'. drupal_render($form['field_pay_date']) .'
'; echo '
'. drupal_render($form['field_seller']) .'
'; echo '
'. drupal_render($form['field_a_nr']) .'
'; echo '
'. drupal_render($form['field_a_count']) .'
'; echo '
'. drupal_render($form['field_bill_me']) .'
'; echo '
'. drupal_render($form['field_bill_text']) .'
'; ?>
3bill.js: $('#node-form > div').prepend('Next Click [Page Down] to show the next element
and [Page Up] to hide the last elment'); // Shows the first hidden Item $('#node-form > div > .item:first').show(); // Adds a function if the Link is clicked $('#node-form > div > a#click').click( function() { // Shows the first hidden element -> the next item $('#node-form > div > .item:hidden:first').show() }); // If you click Page Down the next Element get visible $(document).keyup( function(event) { if (event.keyCode == 34) { $('#node-form > div > .item:hidden:first').show(); } else if (event.keyCode == 33) { $('#node-form > div > .item:visible:last').hide(); } }); });
2.problems For submitting the form I had to have: