tripal_library.synonyms.tpl.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. $library = $variables['node']->library;
  3. // expand the library object to include the synonyms from the library_synonym
  4. // table in chado.
  5. $options = array('return_array' => 1);
  6. $library = tripal_core_expand_chado_vars($library, 'table', 'library_synonym', $options);
  7. $synonyms = $library->library_synonym;
  8. if(count($synonyms) > 0){ ?>
  9. <div id="tripal_library-synonyms-box" class="tripal_library-info-box tripal-info-box">
  10. <div class="tripal_library-info-box-title tripal-info-box-title">Synonyms</div>
  11. <div class="tripal_library-info-box-desc tripal-info-box-desc">The library '<?php print $library->name ?>' has the following synonyms</div><?php
  12. // the $headers array is an array of fields to use as the colum headers.
  13. // additional documentation can be found here
  14. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  15. // This table for the analysis has a vertical header (down the first column)
  16. // so we do not provide headers here, but specify them in the $rows array below.
  17. $headers = array('Synonym');
  18. // the $rows array contains an array of rows where each row is an array
  19. // of values for each column of the table in that row. Additional documentation
  20. // can be found here:
  21. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  22. $rows = array();
  23. foreach ($synonyms as $library_synonym){
  24. $rows[] = array(
  25. $library_synonym->synonym_id->name
  26. );
  27. }
  28. // the $table array contains the headers and rows array as well as other
  29. // options for controlling the display of the table. Additional
  30. // documentation can be found here:
  31. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  32. $table = array(
  33. 'header' => $headers,
  34. 'rows' => $rows,
  35. 'attributes' => array(
  36. 'id' => 'tripal_library-table-synonyms',
  37. ),
  38. 'sticky' => FALSE,
  39. 'caption' => '',
  40. 'colgroups' => array(),
  41. 'empty' => '',
  42. );
  43. // once we have our table array structure defined, we call Drupal's theme_table()
  44. // function to generate the table.
  45. print theme_table($table); ?>
  46. </div><?php
  47. }