tripal_featuremap_references.tpl.php

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

File

tripal_featuremap/theme/templates/tripal_featuremap_references.tpl.php
View source
  1. <?php
  2. $featuremap = $variables['node']->featuremap;
  3. $references = array();
  4. // expand the featuremap object to include the records from the featuremap_dbxref table
  5. $options = array('return_array' => 1);
  6. $featuremap = chado_expand_var($featuremap, 'table', 'featuremap_dbxref', $options);
  7. $featuremap_dbxrefs = $featuremap->featuremap_dbxref;
  8. if (count($featuremap_dbxrefs) > 0 ) {
  9. foreach ($featuremap_dbxrefs as $featuremap_dbxref) {
  10. $references[] = $featuremap_dbxref->dbxref_id;
  11. }
  12. }
  13. if(count($references) > 0){ ?>
  14. <div class="tripal_featuremap-data-block-desc tripal-data-block-desc">External references for this map</div><?php
  15. // the $headers array is an array of fields to use as the colum headers.
  16. // additional documentation can be found here
  17. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  18. $headers = array('Database', 'Accession');
  19. // the $rows array contains an array of rows where each row is an array
  20. // of values for each column of the table in that row. Additional documentation
  21. // can be found here:
  22. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  23. $rows = array();
  24. foreach ($references as $dbxref){
  25. $dbname = $dbxref->db_id->name;
  26. if ($dbxref->db_id->url) {
  27. $dbname = l($dbname, $dbxref->db_id->url, array('attributes' => array('target' => '_blank')));
  28. }
  29. $accession = $dbxref->accession;
  30. if ($dbxref->db_id->urlprefix) {
  31. $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
  32. }
  33. $rows[] = array(
  34. $dbname,
  35. $accession
  36. );
  37. }
  38. // the $table array contains the headers and rows array as well as other
  39. // options for controlling the display of the table. Additional
  40. // documentation can be found here:
  41. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  42. $table = array(
  43. 'header' => $headers,
  44. 'rows' => $rows,
  45. 'attributes' => array(
  46. 'id' => 'tripal_featuremap-table-references',
  47. 'class' => 'tripal-data-table'
  48. ),
  49. 'sticky' => FALSE,
  50. 'caption' => '',
  51. 'colgroups' => array(),
  52. 'empty' => '',
  53. );
  54. // once we have our table array structure defined, we call Drupal's theme_table()
  55. // function to generate the table.
  56. print theme_table($table);
  57. }