tripal_feature_properties.tpl.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. $feature = $variables['node']->feature;
  3. $options = ['return_array' => 1];
  4. $feature = chado_expand_var($feature, 'table', 'featureprop', $options);
  5. $properties = $feature->featureprop;
  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 = ['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 = [];
  16. foreach ($properties as $property) {
  17. $property = chado_expand_var($property, 'field', 'featureprop.value');
  18. $rows[] = [
  19. [
  20. 'data' => ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  21. 'width' => '20%',
  22. ],
  23. urldecode($property->value),
  24. ];
  25. }
  26. // the $table array contains the headers and rows array as well as other
  27. // options for controlling the display of the table. Additional
  28. // documentation can be found here:
  29. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  30. $table = [
  31. 'header' => $headers,
  32. 'rows' => $rows,
  33. 'attributes' => [
  34. 'id' => 'tripal_feature-table-properties',
  35. 'class' => 'tripal-data-table',
  36. ],
  37. 'sticky' => FALSE,
  38. 'caption' => '',
  39. 'colgroups' => [],
  40. 'empty' => '',
  41. ];
  42. // once we have our table array structure defined, we call Drupal's theme_table()
  43. // function to generate the table.
  44. print theme_table($table);
  45. }