tripal_feature_synonyms.tpl.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. $feature = $variables['node']->feature;
  3. // expand the feature object to include the synonyms from the feature_synonym
  4. // table in chado.
  5. $options = array('return_array' => 1);
  6. $feature = chado_expand_var($feature, 'table', 'feature_synonym', $options);
  7. $synonyms = $feature->feature_synonym;
  8. if(count($synonyms) > 0){ ?>
  9. <div class="tripal_feature-data-block-desc tripal-data-block-desc">The feature '<?php print $feature->name ?>' has the following synonyms</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. // This table for the analysis has a vertical header (down the first column)
  14. // so we do not provide headers here, but specify them in the $rows array below.
  15. $headers = array('Synonym');
  16. // the $rows array contains an array of rows where each row is an array
  17. // of values for each column of the table in that row. Additional documentation
  18. // can be found here:
  19. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  20. $rows = array();
  21. foreach ($synonyms as $feature_synonym){
  22. $rows[] = array(
  23. $feature_synonym->synonym_id->name
  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 = array(
  31. 'header' => $headers,
  32. 'rows' => $rows,
  33. 'attributes' => array(
  34. 'id' => 'tripal_feature-table-synonyms',
  35. 'class' => 'tripal-data-table'
  36. ),
  37. 'sticky' => FALSE,
  38. 'caption' => '',
  39. 'colgroups' => array(),
  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. }