tripal_fields_layout_generic.tpl.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. drupal_add_js('misc/collapse.js');
  3. $panels = $variables['element']['#panels'];
  4. $fields = $variables['element']['#fields'];
  5. // TODO, the horz_table variable needs to be set in a variable and checked here.
  6. $horz_table = TRUE;
  7. // Group fields into panels
  8. $content = '';
  9. $toc = '';
  10. foreach ($panels AS $panel_id => $panel) {
  11. $panel_fields = $fields[$panel_id];
  12. $collapsible_item = array('element' => array());
  13. // If the format is horizontal table then format the fields in tabular format.
  14. if ($horz_table) {
  15. $rows = array();
  16. foreach ($panel_fields as $field) {
  17. $rows[] = array(
  18. array(
  19. 'data' => $field['#title'],
  20. 'header' => TRUE,
  21. 'width' => '20%',
  22. ),
  23. $field[0]['#markup']
  24. );
  25. }
  26. $collapsible_item['element']['#description'] = theme_table(array(
  27. 'header' => array(),
  28. 'rows' => $rows,
  29. 'attributes' => array(
  30. 'id' => '', // TODO: need to add an ID
  31. 'class' => 'tripal-data-table'
  32. ),
  33. 'sticky' => FALSE,
  34. 'caption' => '',
  35. 'colgroups' => array(),
  36. 'empty' => '',
  37. ));
  38. }
  39. // If no format is provided then use the default Drupal render.
  40. else {
  41. $collapsible_item['element']['#description'] = render($panel_fields);
  42. }
  43. // If this is not the base content then the field should be collapsible.
  44. if ($panel->name != 'te_base') {
  45. $collapsible_item['element']['#title'] = $panel->label;
  46. $collapsible_item['element']['#children'] = '';
  47. $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
  48. $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
  49. $toc_item_id = $panel_id;
  50. $toc .= "<div class=\"tripal_toc_list_item\"><a id=\"" . $panel->name . "\" class=\"tripal_toc_list_item_link\" href=\"?pane=" . $panel->name . "\">" . $panel->label . "</a></div>";
  51. $content .= theme('fieldset', $collapsible_item);
  52. }
  53. // The base field should just be the fields
  54. else {
  55. $content .= render($panel_fields);
  56. }
  57. }
  58. $bundle_type = ''; // TODO: need to add the bundle type ?>
  59. <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-contents-table">
  60. <tr class="tripal-contents-table-tr">
  61. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
  62. print $toc; ?>
  63. </td>
  64. <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
  65. // print the rendered content
  66. print $content; ?>
  67. </td>
  68. </tr>
  69. </table>