tripal_featuremap_properties.tpl.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. $featuremap = $variables['node']->featuremap;
  3. $options = ['return_array' => 1];
  4. $featuremap = chado_expand_var($featuremap, 'table', 'featuremapprop', $options);
  5. $properties = $featuremap->featuremapprop;
  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', 'featuremapprop.value');
  18. $rows[] = [
  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 = [
  28. 'header' => $headers,
  29. 'rows' => $rows,
  30. 'attributes' => [
  31. 'id' => 'tripal_featuremap-table-properties',
  32. 'class' => 'tripal-data-table',
  33. ],
  34. 'sticky' => FALSE,
  35. 'caption' => '',
  36. 'colgroups' => [],
  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. }