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

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