node--chado-library.tpl.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. // Purpose: This template provides the layout of the library node (page)
  3. // using the same templates used for the various library content blocks.
  4. //
  5. // To Customize the Libray 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. $library = $variables['node']->library;
  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']['library']) {
  29. $no_sidebar = 1;
  30. }
  31. if ($teaser) {
  32. print theme('tripal_library_teaser',$variables);
  33. }
  34. else { ?>
  35. <script type="text/javascript">
  36. (function ($) {
  37. Drupal.behaviors.libraryBehavior = {
  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_library_toc_list').append('<li><a href="#'+id+'" class="tripal_library_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_library_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_library_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_library-"+block[1]+"-box").show();
  75. } else {
  76. $("#tripal_library-base-box").show();
  77. }
  78. $("#tripal_library_toc").height($("#tripal_library-base-box").parent().height());
  79. }
  80. };
  81. })(jQuery);
  82. </script>
  83. <div id="tripal_library_details" class="tripal_details">
  84. <!-- Basic Details Theme -->
  85. <?php print theme('tripal_library_base',$node); ?>
  86. <!-- External References -->
  87. <?php print theme('tripal_library_references',$node); ?>
  88. <!-- Properties -->
  89. <?php print theme('tripal_library_properties',$node); ?>
  90. <!-- Terms -->
  91. <?php print theme('tripal_library_terms',$node); ?>
  92. <!-- Synonyms -->
  93. <?php print theme('tripal_library_synonyms',$node); ?>
  94. <!-- Resource Blocks CCK elements --><?php
  95. for($i = 0; $i < count($node->field_resource_titles); $i++){
  96. if($node->field_resource_titles[$i]['value']){ ?>
  97. <div id="tripal_library-resource_<?php print $i?>-box" class="tripal_library-info-box tripal-info-box">
  98. <div class="tripal_library-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  99. <?php print $node->field_resource_blocks[$i]['value']; ?>
  100. </div><?php
  101. }
  102. }?>
  103. <!-- Let modules add more content -->
  104. <?php print $content ?>
  105. </div>
  106. <!-- Table of contents -->
  107. <div id="tripal_library_toc" class="tripal_toc">
  108. <div id="tripal_library_toc_title" class="tripal_toc_title">Resources</div>
  109. <ul id="tripal_library_toc_list" class="tripal_toc_list">
  110. <!-- Resource Links CCK elements --><?php
  111. for($i = 0; $i < count($node->field_resource_links); $i++){
  112. if($node->field_resource_links[$i]['value']){
  113. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  114. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  115. }
  116. }?>
  117. <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
  118. </ul>
  119. </div>
  120. <?php } ?>