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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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){
  22. $(".tripal-info-box").hide();
  23. // iterate through all of the info boxes and add their titles
  24. // to the table of contents
  25. $(".tripal-info-box-title").each(function(){
  26. var parent = $(this).parent();
  27. var id = $(parent).attr('id');
  28. var title = $(this).text();
  29. $('#tripal_<?php print $ttype?>_toc_list').append('<li><a href="#'+id+'" class="tripal_<?php print $ttype?>_toc_item">'+title+'</a></li>');
  30. });
  31. // when a title in the table of contents is clicked, then
  32. // show the corresponding item in the details box
  33. $(".tripal_<?php print $ttype?>_toc_item").click(function(){
  34. $(".tripal-info-box").hide();
  35. href = $(this).attr('href');
  36. if(href.match(/^#/)){
  37. //alert("correct: " + href);
  38. }
  39. else{
  40. tmp = href.replace(/^.*?#/, "#");
  41. href = tmp;
  42. //alert("fixed: " + href);
  43. }
  44. $(href).fadeIn('slow');
  45. return false;
  46. });
  47. // we want the base details to show up when the page is first shown
  48. // unless we're using the feature browser then we want that page to show
  49. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  50. if(block == null){
  51. block = window.location.href.match(/[\?|\&]block=(.+)/)
  52. }
  53. if(block != null){
  54. $("#tripal_<?php print $ttype?>-"+block[1]+"-box").show();
  55. }
  56. else {
  57. $("#tripal_<?php print $ttype?>-base-box").show();
  58. }
  59. }
  60. };
  61. })(jQuery);
  62. </script>
  63. <div id="tripal_<?php print $ttype?>_content" class="tripal-contents"> <?php
  64. if ($page['tripal_sidebar']) { ?>
  65. <div id="tripal-sidebar" class="column sidebar">
  66. <div class="section">
  67. <?php print render($page["chado_" . $ttype . " _toc"]); ?>
  68. </div>
  69. </div><?php
  70. } ?>
  71. <table id="tripal-contents-table">
  72. <tr class="tripal-contents-table-tr">
  73. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left">
  74. <ul id="tripal_<?php print $ttype?>_toc_list" class="tripal_toc_list">
  75. <!-- Resource Links CCK elements --><?php
  76. if(property_exists($node, 'field_resource_links')) {
  77. for($i = 0; $i < count($node->field_resource_links); $i++){
  78. if($node->field_resource_links[$i]['value']){
  79. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  80. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  81. }
  82. }
  83. }
  84. ?>
  85. </ul>
  86. </td>
  87. <td class="tripal-contents-table-td-data" align="left" width="100%">
  88. <!-- Resource Blocks CCK elements --> <?php
  89. if (property_exists($node, 'field_resource_titles')) {
  90. for ($i = 0; $i < count($node->field_resource_titles); $i++){
  91. if ($node->field_resource_titles[$i]['value']){ ?>
  92. <div id="tripal_<?php print $ttype?>-resource_<?php print $i?>-box" class="tripal_<?php print $ttype?>-info-box tripal-info-box">
  93. <div class="tripal_<?php print $ttype?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  94. <?php print $node->field_resource_blocks[$i]['value']; ?>
  95. </div> <?php
  96. }
  97. }
  98. }?>
  99. <!-- Let modules add more content -->
  100. <?php
  101. foreach ($content as $key => $values) {
  102. if (array_key_exists('#value', $values)) {
  103. print $content[$key]['#value'];
  104. }
  105. }
  106. ?>
  107. </td>
  108. </tr>
  109. </table>
  110. </div>
  111. <?php
  112. } ?>