tripal_library_terms.tpl.php

  1. 2.x tripal_library/theme/templates/tripal_library_terms.tpl.php
  2. 3.x legacy/tripal_library/theme/templates/tripal_library_terms.tpl.php
1 theme call to tripal_library_terms.tpl.php
tripal_library_node_view in legacy/tripal_library/includes/tripal_library.chado_node.inc
Implements hook_node_view(). Acts on all content types

File

legacy/tripal_library/theme/templates/tripal_library_terms.tpl.php
View source
  1. <?php
  2. $library = $variables['node']->library;
  3. $options = array('return_array' => 1);
  4. $library = chado_expand_var($library, 'table', 'library_cvterm', $options);
  5. $terms = $library->library_cvterm;
  6. // order the terms by CV
  7. $s_terms = array();
  8. if ($terms) {
  9. foreach ($terms as $term) {
  10. $s_terms[$term->cvterm_id->cv_id->name][] = $term;
  11. }
  12. }
  13. if (count($s_terms) > 0) { ?>
  14. <div class="tripal_library-data-block-desc tripal-data-block-desc">The following terms have been associated with this <?php print $node->library->type_id->name ?>:</div> <?php
  15. // iterate through each term
  16. $i = 0;
  17. foreach ($s_terms as $cv => $terms) {
  18. // the $headers array is an array of fields to use as the colum headers.
  19. // additional documentation can be found here
  20. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  21. $headers = array('Term', 'Definition');
  22. // the $rows array contains an array of rows where each row is an array
  23. // of values for each column of the table in that row. Additional documentation
  24. // can be found here:
  25. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  26. $rows = array();
  27. foreach ($terms as $term) {
  28. $accession = $term->cvterm_id->dbxref_id->accession;
  29. if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
  30. $accession = $term->cvterm_id->dbxref_id->db_id->name . ":" . $term->cvterm_id->dbxref_id->accession;
  31. }
  32. if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
  33. $accession = l($accession, $term->cvterm_id->dbxref_id->db_id->urlprefix . $accession, array('attributes' => array("target" => '_blank')));
  34. }
  35. $rows[] = array(
  36. $accession,
  37. $term->cvterm_id->name
  38. );
  39. }
  40. // the $table array contains the headers and rows array as well as other
  41. // options for controlling the display of the table. Additional
  42. // documentation can be found here:
  43. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  44. $table = array(
  45. 'header' => $headers,
  46. 'rows' => $rows,
  47. 'attributes' => array(
  48. 'id' => "tripal_library-table-terms-$i",
  49. 'class' => 'tripal-data-table'
  50. ),
  51. 'sticky' => FALSE,
  52. 'caption' => '<b>Vocabulary: ' . ucwords(preg_replace('/_/', ' ', $cv)) . '</b>',
  53. 'colgroups' => array(),
  54. 'empty' => '',
  55. );
  56. // once we have our table array structure defined, we call Drupal's theme_table()
  57. // function to generate the table.
  58. print theme_table($table);
  59. $i++;
  60. }
  61. } ?>