tripal_example_base.tpl.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. $example = $variables['node']->example; ?>
  3. <div class="tripal_example-data-block-desc tripal-data-block-desc"></div> <?php
  4. // the $headers array is an array of fields to use as the column headers.
  5. // additional documentation can be found here
  6. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  7. // This table for the analysis has a vertical header (down the first column)
  8. // so we do not provide headers here, but specify them in the $rows array below.
  9. $headers = array();
  10. // the $rows array contains an array of rows where each row is an array
  11. // of values for each column of the table in that row. Additional documentation
  12. // can be found here:
  13. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  14. $rows = array();
  15. // Unique Name row
  16. $rows[] = array(
  17. array(
  18. 'data' => 'Unique Name',
  19. 'header' => TRUE
  20. ),
  21. $example->uniquename
  22. );
  23. // Type row
  24. $rows[] = array(
  25. array(
  26. 'data' => 'Type',
  27. 'header' => TRUE
  28. ),
  29. $example->type_id->name
  30. );
  31. // Organism row
  32. $organism = $example->organism_id->genus ." " . $example->organism_id->species ." (" . $example->organism_id->common_name .")";
  33. if (property_exists($example->organism_id, 'nid')) {
  34. $organism = l("<i>" . $example->organism_id->genus . " " . $example->organism_id->species . "</i> (" . $example->organism_id->common_name .")", "node/".$example->organism_id->nid, array('html' => TRUE));
  35. }
  36. $rows[] = array(
  37. array(
  38. 'data' => 'Organism',
  39. 'header' => TRUE,
  40. ),
  41. $organism
  42. );
  43. // allow site admins to see the example ID
  44. if (user_access('view ids')) {
  45. // Feature ID
  46. $rows[] = array(
  47. array(
  48. 'data' => 'Example ID',
  49. 'header' => TRUE,
  50. 'class' => 'tripal-site-admin-only-table-row',
  51. ),
  52. array(
  53. 'data' => $example->example_id,
  54. 'class' => 'tripal-site-admin-only-table-row',
  55. ),
  56. );
  57. }
  58. // the $table array contains the headers and rows array as well as other options
  59. // for controlling the display of the table. Additional documentation can be
  60. // found here:
  61. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  62. $table = array(
  63. 'header' => $headers,
  64. 'rows' => $rows,
  65. 'attributes' => array(
  66. 'id' => 'tripal_example-table-base',
  67. 'class' => 'tripal-data-table'
  68. ),
  69. 'sticky' => FALSE,
  70. 'caption' => '',
  71. 'colgroups' => array(),
  72. 'empty' => '',
  73. );
  74. // once we have our table array structure defined, we call Drupal's
  75. // theme_table() function to generate the table.
  76. print theme_table($table); ?>
  77. <div style="text-align: justify"><?php print $example->description ?></div>