tripal_library_properties.tpl.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. $library = $variables['node']->library;
  3. $options = array('return_array' => 1);
  4. $library = chado_expand_var($library, 'table', 'libraryprop', $options);
  5. $props = $library->libraryprop;
  6. if (!$props) {
  7. return;
  8. }
  9. // iterate through the properties and remove the 'library_description' as it is
  10. // already displayed on the base template.
  11. $properties = array();
  12. foreach ($props as $prop) {
  13. if ($prop->type_id->name == 'Library Description') {
  14. continue;
  15. }
  16. $properties[] = $prop;
  17. }
  18. if(count($properties) > 0){
  19. // the $headers array is an array of fields to use as the colum headers.
  20. // additional documentation can be found here
  21. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  22. $headers = array('Property Name', 'Value');
  23. // the $rows array contains an array of rows where each row is an array
  24. // of values for each column of the table in that row. Additional documentation
  25. // can be found here:
  26. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  27. $rows = array();
  28. foreach ($properties as $property){
  29. $property = chado_expand_var($property,'field','libraryprop.value');
  30. $rows[] = array(
  31. ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  32. urldecode($property->value)
  33. );
  34. }
  35. // the $table array contains the headers and rows array as well as other
  36. // options for controlling the display of the table. Additional
  37. // documentation can be found here:
  38. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  39. $table = array(
  40. 'header' => $headers,
  41. 'rows' => $rows,
  42. 'attributes' => array(
  43. 'id' => 'tripal_library-table-properties',
  44. 'class' => 'tripal-data-table'
  45. ),
  46. 'sticky' => FALSE,
  47. 'caption' => '',
  48. 'colgroups' => array(),
  49. 'empty' => '',
  50. );
  51. // once we have our table array structure defined, we call Drupal's theme_table()
  52. // function to generate the table.
  53. print theme_table($table);
  54. }