tripal_organism_properties.tpl.php 1.7 KB

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