tripal_fields_layout_generic.tpl.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. 'nowrap' => 'nowrap'
  23. ),
  24. $field[0]['#markup']
  25. );
  26. }
  27. $collapsible_item['element']['#description'] = theme_table(array(
  28. 'header' => array(),
  29. 'rows' => $rows,
  30. 'attributes' => array(
  31. 'id' => '', // TODO: need to add an ID
  32. 'class' => 'tripal-data-table'
  33. ),
  34. 'sticky' => FALSE,
  35. 'caption' => '',
  36. 'colgroups' => array(),
  37. 'empty' => '',
  38. ));
  39. }
  40. // If no format is provided then use the default Drupal render.
  41. else {
  42. $collapsible_item['element']['#description'] = render($panel_fields);
  43. }
  44. // If this is not the base content then the field should be collapsible.
  45. if ($panel->name != 'te_base') {
  46. $collapsible_item['element']['#title'] = $panel->label;
  47. $collapsible_item['element']['#children'] = '';
  48. $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
  49. $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
  50. $toc_item_id = $panel_id;
  51. $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>";
  52. $content .= theme('fieldset', $collapsible_item);
  53. }
  54. // The base field should just be the fields
  55. else {
  56. $content .= render($panel_fields);
  57. }
  58. }
  59. $bundle_type = ''; // TODO: need to add the bundle type ?>
  60. <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-contents-table">
  61. <tr class="tripal-contents-table-tr">
  62. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
  63. print $toc; ?>
  64. </td>
  65. <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
  66. // print the rendered content
  67. print $content; ?>
  68. </td>
  69. </tr>
  70. </table>