node--chado-generic.tpl.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. // Purpose: This template provides a generic layout for all Tripal nodes (page)
  3. // get the template type of node (e.g. if type == chado_organism then template type == organism)
  4. $ttype = $variables['type'];
  5. $ttype = preg_replace('/chado_/','', $ttype);
  6. // get the template settings
  7. $template_settings = theme_get_setting('tripal');
  8. // toggle the sidebar if desired
  9. $no_sidebar = 0;
  10. if (is_array($template_settings['tripal_no_sidebar']) and
  11. $template_settings['tripal_no_sidebar'][$ttype]) {
  12. $no_sidebar = 1;
  13. }
  14. if ($teaser) {
  15. print theme('tripal_' . $ttype . '_teaser', $variables);
  16. }
  17. else { ?>
  18. <script type="text/javascript">
  19. (function ($) {
  20. Drupal.behaviors.<?php print $ttype?>Behavior = {
  21. attach: function (context, settings){ <?php
  22. // hide the resource sidbar if requested and strech the details section
  23. if ($no_sidebar) { ?>
  24. $(".tripal_toc").hide();
  25. $(".tripal_details").addClass("tripal_details_full");
  26. $(".tripal_details_full").removeClass("tripal_details"); <?php
  27. }
  28. // use default resource sidebar
  29. else { ?>
  30. $(".tripal-info-box").hide(); <?php
  31. } ?>
  32. // iterate through all of the info boxes and add their titles
  33. // to the table of contents
  34. $(".tripal-info-box-title").each(function(){
  35. var parent = $(this).parent();
  36. var id = $(parent).attr('id');
  37. var title = $(this).text();
  38. $('#tripal_<?php print $ttype?>_toc_list').append('<li><a href="#'+id+'" class="tripal_<?php print $ttype?>_toc_item">'+title+'</a></li>');
  39. });
  40. // when a title in the table of contents is clicked, then
  41. // show the corresponding item in the details box
  42. $(".tripal_<?php print $ttype?>_toc_item").click(function(){
  43. $(".tripal-info-box").hide();
  44. href = $(this).attr('href');
  45. if(href.match(/^#/)){
  46. //alert("correct: " + href);
  47. }
  48. else{
  49. tmp = href.replace(/^.*?#/, "#");
  50. href = tmp;
  51. //alert("fixed: " + href);
  52. }
  53. $(href).fadeIn('slow');
  54. return false;
  55. });
  56. // we want the base details to show up when the page is first shown
  57. // unless we're using the feature browser then we want that page to show
  58. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  59. if(block == null){
  60. block = window.location.href.match(/[\?|\&]block=(.+)/)
  61. }
  62. if(block != null){
  63. $("#tripal_<?php print $ttype?>-"+block[1]+"-box").show();
  64. }
  65. else {
  66. $("#tripal_<?php print $ttype?>-base-box").show();
  67. }
  68. }
  69. };
  70. })(jQuery);
  71. </script>
  72. <div id="tripal_<?php print $ttype?>_content" class="tripal_contents"> <?php
  73. if ($page['tripal_sidebar']) { ?>
  74. <div id="tripal-sidebar" class="column sidebar">
  75. <div class="section">
  76. <?php print render($page["chado_" . $ttype . " _toc"]); ?>
  77. </div>
  78. </div><?php
  79. } ?>
  80. <table id="tripal_contents_table">
  81. <tr class="tripal_contents_table_tr">
  82. <td nowrap class="tripal_contents_table_td tripal_contents_table_td_toc" align="left">
  83. <div id="tripal_<?php print $ttype?>_toc" class="tripal_toc">
  84. <ul id="tripal_<?php print $ttype?>_toc_list" class="tripal_toc_list">
  85. <!-- Resource Links CCK elements --><?php
  86. if(property_exists($node, 'field_resource_links')) {
  87. for($i = 0; $i < count($node->field_resource_links); $i++){
  88. if($node->field_resource_links[$i]['value']){
  89. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  90. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  91. }
  92. }
  93. }
  94. ?>
  95. </ul>
  96. </div>
  97. </td>
  98. <td class="tripal_contents_table_td" align="left" width="100%">
  99. <div id="tripal_<?php print $ttype?>_details" class="tripal_details">
  100. <!-- Resource Blocks CCK elements --> <?php
  101. if (property_exists($node, 'field_resource_titles')) {
  102. for ($i = 0; $i < count($node->field_resource_titles); $i++){
  103. if ($node->field_resource_titles[$i]['value']){ ?>
  104. <div id="tripal_<?php print $ttype?>-resource_<?php print $i?>-box" class="tripal_<?php print $ttype?>-info-box tripal-info-box">
  105. <div class="tripal_<?php print $ttype?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  106. <?php print $node->field_resource_blocks[$i]['value']; ?>
  107. </div> <?php
  108. }
  109. }
  110. }?>
  111. <!-- Let modules add more content -->
  112. <?php
  113. foreach ($content as $key => $values) {
  114. if (array_key_exists('#value', $values)) {
  115. print $content[$key]['#value'];
  116. }
  117. }
  118. ?>
  119. </div>
  120. </td>
  121. </tr>
  122. </table>
  123. </div>
  124. <?php
  125. } ?>