tripal_fields_layout_generic.tpl.php 2.4 KB

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