node--chado-stock.tpl.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. // Purpose: This template provides the layout of the stock node (page)
  3. // using the same templates used for the various stock content blocks.
  4. //
  5. // To Customize the Stock 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. $stock = $variables['node']->stock;
  23. // get the template settings
  24. $template_settings = theme_get_setting('tripal');
  25. // toggle the sidebar if desired
  26. $no_sidebar = 0;
  27. if (is_array($template_settings['tripal_no_sidebar']) and
  28. $template_settings['tripal_no_sidebar']['stock']) {
  29. $no_sidebar = 1;
  30. }
  31. if ($teaser) {
  32. print theme('tripal_stock_teaser',$node);
  33. }
  34. else { ?>
  35. <script type="text/javascript">
  36. (function ($) {
  37. Drupal.behaviors.stockBehavior = {
  38. attach: function (context, settings){ <?php
  39. if ($no_sidebar) { ?>
  40. // hide the resource side bar and strech the details section
  41. $(".tripal_toc").hide();
  42. $(".tripal_details").addClass("tripal_details_full");
  43. $(".tripal_details_full").removeClass("tripal_details"); <?php
  44. } else { ?>
  45. // use default resource sidebar
  46. $(".tripal-info-box").hide(); <?php
  47. } ?>
  48. // iterate through all of the info boxes and add their titles
  49. // to the table of contents
  50. $(".tripal-info-box-title").each(function(){
  51. var parent = $(this).parent();
  52. var id = $(parent).attr('id');
  53. var title = $(this).text();
  54. $('#tripal_stock_toc_list').append('<li><a href="#'+id+'" class="tripal_stock_toc_item">'+title+'</a></li>');
  55. });
  56. // when a title in the table of contents is clicked, then
  57. // show the corresponding item in the details box
  58. $(".tripal_stock_toc_item").click(function(){
  59. $(".tripal-info-box").hide();
  60. href = $(this).attr('href');
  61. $(href).fadeIn('slow');
  62. // we want to make sure our table of contents and the details
  63. // box stay the same height
  64. $("#tripal_stock_toc").height($(href).parent().height());
  65. return false;
  66. });
  67. // we want the base details to show up when the page is first shown
  68. // unless the user specified a specific block
  69. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  70. if(block == null){
  71. block = window.location.href.match(/[\?|\&]block=(.+)/)
  72. }
  73. if(block != null){
  74. $("#tripal_stock-"+block[1]+"-box").show();
  75. } else {
  76. $("#tripal_stock-base-box").show();
  77. }
  78. $("#tripal_stock_toc").height($("#tripal_stock-base-box").parent().height());
  79. }
  80. };
  81. })(jQuery);
  82. </script>
  83. <div id="tripal_stock_details" class="tripal_details">
  84. <!-- Base Theme -->
  85. <?php print theme('tripal_stock_base',$node); ?>
  86. <!-- Cross References -->
  87. <?php print theme('tripal_stock_references',$node); ?>
  88. <!-- Properties -->
  89. <?php print theme('tripal_stock_properties',$node); ?>
  90. <!-- Synonyms -->
  91. <?php print theme('tripal_stock_synonyms',$node); ?>
  92. <!-- Relationships -->
  93. <?php print theme('tripal_stock_relationships',$node); ?>
  94. <!-- Stock Collections -->
  95. <?php print theme('tripal_stock_collections',$node); ?>
  96. <!-- Stock Genotypes -->
  97. <?php print theme('tripal_stock_genotypes',$node); ?>
  98. <!-- Resource Blocks CCK elements --><?php
  99. for($i = 0; $i < count($node->field_resource_titles); $i++){
  100. if($node->field_resource_titles[$i]['value']){ ?>
  101. <div id="tripal_stock-resource_<?php print $i?>-box" class="tripal_stock-info-box tripal-info-box">
  102. <div class="tripal_stock-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  103. <?php print $node->field_resource_blocks[$i]['value']; ?>
  104. </div><?php
  105. }
  106. }?>
  107. <!-- Let modules add more content -->
  108. <?php print $content; ?>
  109. </div>
  110. <!-- Table of contents -->
  111. <div id="tripal_stock_toc" class="tripal_toc">
  112. <div id="tripal_stock_toc_title" class="tripal_toc_title">Resources</div>
  113. <span id="tripal_stock_toc_desc" class="tripal_toc_desc"></span>
  114. <ul id="tripal_stock_toc_list" class="tripal_toc_list">
  115. <!-- Resource Links CCK elements --><?php
  116. for($i = 0; $i < count($node->field_resource_links); $i++){
  117. if($node->field_resource_links[$i]['value']){
  118. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  119. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  120. }
  121. }?>
  122. <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
  123. </ul>
  124. </div>
  125. <?php } ?>