tripal_feature_properties.tpl.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. $feature = $variables['node']->feature;
  3. $options = array('return_array' => 1);
  4. $feature = tripal_core_expand_chado_vars($feature, 'table', 'featureprop', $options);
  5. $properties = $feature->featureprop;
  6. if(count($properties) > 0){ ?>
  7. <div id="tripal_feature-properties-box" class="tripal_feature-info-box tripal-info-box">
  8. <div class="tripal_feature-info-box-title tripal-info-box-title">Properties</div> <?php
  9. // the $headers array is an array of fields to use as the colum headers.
  10. // additional documentation can be found here
  11. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  12. $headers = array('Property Name', 'Value');
  13. // the $rows array contains an array of rows where each row is an array
  14. // of values for each column of the table in that row. Additional documentation
  15. // can be found here:
  16. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  17. $rows = array();
  18. foreach ($properties as $property){
  19. $property = tripal_core_expand_chado_vars($property,'field','featureprop.value');
  20. $rows[] = array(
  21. ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  22. urldecode($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 = array(
  30. 'header' => $headers,
  31. 'rows' => $rows,
  32. 'attributes' => array(
  33. 'id' => 'tripal_feature-table-properties',
  34. ),
  35. 'sticky' => FALSE,
  36. 'caption' => '',
  37. 'colgroups' => array(),
  38. 'empty' => '',
  39. );
  40. // once we have our table array structure defined, we call Drupal's theme_table()
  41. // function to generate the table.
  42. print theme_table($table); ?>
  43. </div> <?php
  44. }