tripal_library_synonyms.tpl.php 1.9 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 = ['return_array' => 1];
  6. $library = chado_expand_var($library, 'table', 'library_synonym', $options);
  7. $synonyms = $library->library_synonym;
  8. if (count($synonyms) > 0) { ?>
  9. <div class="tripal_library-data-block-desc tripal-data-block-desc">The
  10. library '<?php print $library->name ?>' has the following
  11. 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 = ['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 = [];
  23. foreach ($synonyms as $library_synonym) {
  24. $rows[] = [
  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 = [
  33. 'header' => $headers,
  34. 'rows' => $rows,
  35. 'attributes' => [
  36. 'id' => 'tripal_library-table-synonyms',
  37. 'class' => 'tripal-data-table',
  38. ],
  39. 'sticky' => FALSE,
  40. 'caption' => '',
  41. 'colgroups' => [],
  42. 'empty' => '',
  43. ];
  44. // once we have our table array structure defined, we call Drupal's theme_table()
  45. // function to generate the table.
  46. print theme_table($table);
  47. }