tripal_analysis_properties.tpl.php 1.8 KB

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