node--chado-organism.tpl.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. // Purpose: This template provides the layout of the organism node (page)
  3. // using the same templates used for the various feature content blocks.
  4. //
  5. // To Customize the Featture Node Page:
  6. // - This Template: customize basic layout and which elements are included
  7. // - Using Panels: Override the node page using Panels3 and place the blocks
  8. // of content as you please. This method requires no programming. See
  9. // the Tripal User Guide for more details
  10. // - Block Templates: customize the content/layout of each block of stock
  11. // content. These templates are found in the tripal_stock subdirectory
  12. //
  13. // Variables Available:
  14. // - $node: a standard object which contains all the fields associated with
  15. // nodes including nid, type, title, taxonomy. It also includes stock
  16. // specific fields such as stock_name, uniquename, stock_type, synonyms,
  17. // properties, db_references, object_relationships, subject_relationships,
  18. // organism, etc.
  19. // NOTE: For a full listing of fields available in the node object the
  20. // print_r $node line below or install the Drupal Devel module which
  21. // provides an extra tab at the top of the node page labelled Devel
  22. dpm($variables);
  23. $organism = $variables['node']->organism;
  24. // get the template settings
  25. $template_settings = theme_get_setting('tripal');
  26. // toggle the sidebar if desired
  27. $no_sidebar = 0;
  28. if (is_array($template_settings['tripal_no_sidebar']) and
  29. $template_settings['tripal_no_sidebar']['organism']) {
  30. $no_sidebar = 1;
  31. }
  32. if ($teaser) {
  33. print theme('tripal_organism_teaser', $variables);
  34. }
  35. else { ?>
  36. <script type="text/javascript">
  37. (function ($) {
  38. Drupal.behaviors.organismBehavior = {
  39. attach: function (context, settings){<?php
  40. // hide the resource sidbar if requested and strech the details section
  41. if ($no_sidebar) { ?>
  42. $(".tripal_toc").hide();
  43. $(".tripal_details").addClass("tripal_details_full");
  44. $(".tripal_details_full").removeClass("tripal_details"); <?php
  45. }
  46. // use default resource sidebar
  47. else { ?>
  48. $(".tripal-info-box").hide();
  49. // set the widths of the details and sidebar sections so they can work
  50. // seemlessly with any theme.
  51. total_width = $(".tripal_contents").width();
  52. details_width = (total_width * 0.70) - 52; // 52 == 20 x 2 left/right padding + 10 right margin + 2pt border
  53. toc_width = (total_width * 0.30) - 42; // 42 == 20 x 2 left/right padding + 2pt border
  54. // don't let sidebar get wider than 200px
  55. if (toc_width > 200) {
  56. details_width += toc_width - 200;
  57. toc_width = 200;
  58. }
  59. $('#tripal_organism_toc').width(toc_width);
  60. $('#tripal_organism_details').width(details_width); <?php
  61. } ?>
  62. // iterate through all of the info boxes and add their titles
  63. // to the table of contents
  64. $(".tripal-info-box-title").each(function(){
  65. var parent = $(this).parent();
  66. var id = $(parent).attr('id');
  67. var title = $(this).text();
  68. $('#tripal_organism_toc_list').append('<li><a href="#'+id+'" class="tripal_organism_toc_item">'+title+'</a></li>');
  69. });
  70. // when a title in the table of contents is clicked, then
  71. // show the corresponding item in the details box
  72. $(".tripal_organism_toc_item").click(function(){
  73. $(".tripal-info-box").hide();
  74. href = $(this).attr('href');
  75. if(href.match(/^#/)){
  76. //alert("correct: " + href);
  77. }
  78. else{
  79. tmp = href.replace(/^.*?#/, "#");
  80. href = tmp;
  81. //alert("fixed: " + href);
  82. }
  83. $(href).fadeIn('slow');
  84. // we want to make sure our table of contents and the details
  85. // box stay the same height
  86. $("#tripal_organism_toc").height($(href).parent().height());
  87. return false;
  88. });
  89. // we want the base details to show up when the page is first shown
  90. // unless we're using the feature browser then we want that page to show
  91. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  92. if(block == null){
  93. block = window.location.href.match(/[\?|\&]block=(.+)/)
  94. }
  95. if(block != null){
  96. $("#tripal_organism-"+block[1]+"-box").show();
  97. }
  98. else if(window.location.href.match(/\?page=\d+/)){
  99. $("#tripal_organism-feature_browser-box").show();
  100. }
  101. else {
  102. $("#tripal_organism-base-box").show();
  103. }
  104. $("#tripal_organism_toc").height($("#tripal_organism-base-box").parent().height());
  105. }
  106. };
  107. })(jQuery);
  108. </script>
  109. <div id="tripal_organism_content" class="tripal_contents">
  110. <div id="tripal_organism_details" class="tripal_details">
  111. <!-- Resource Blocks CCK elements --> <?php
  112. if (property_exists($node, 'field_resource_titles')) {
  113. for ($i = 0; $i < count($node->field_resource_titles); $i++){
  114. if ($node->field_resource_titles[$i]['value']){ ?>
  115. <div id="tripal_organism-resource_<?php print $i?>-box" class="tripal_organism-info-box tripal-info-box">
  116. <div class="tripal_organism-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  117. <?php print $node->field_resource_blocks[$i]['value']; ?>
  118. </div> <?php
  119. }
  120. }
  121. }?>
  122. <!-- Let modules add more content -->
  123. <?php
  124. foreach ($content as $key => $values) {
  125. if (array_key_exists('#value', $values)) {
  126. print $content[$key]['#value'];
  127. }
  128. }
  129. ?>
  130. </div>
  131. <!-- Table of contents -->
  132. <div id="tripal_organism_toc" class="tripal_toc">
  133. <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
  134. <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
  135. <ul id="tripal_organism_toc_list" class="tripal_toc_list">
  136. <!-- Resource Links CCK elements --><?php
  137. if(property_exists($node, 'field_resource_links')) {
  138. for($i = 0; $i < count($node->field_resource_links); $i++){
  139. if($node->field_resource_links[$i]['value']){
  140. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  141. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  142. }
  143. }
  144. }
  145. ?>
  146. </ul>
  147. </div>
  148. </div>
  149. <?php
  150. } ?>