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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. $node_type = $variables['type']; ?>
  5. <script type="text/javascript">
  6. (function ($) {
  7. Drupal.behaviors.<?php print $node_type?>Behavior = {
  8. attach: function (context, settings){
  9. // hide all but the first data block
  10. $(".tripal-data-block").hide().filter(":first-child").show();
  11. // when a title in the table of contents is clicked, then
  12. // show the corresponding item in the details box
  13. $(".tripal_toc_list_item_link").click(function(){
  14. var id = $(this).attr('id') + "-tripal-data-block";
  15. $(".tripal-data-block").hide().filter("#"+ id).show();
  16. return false;
  17. });
  18. // if a ?block= is specified in the URL then we want to show the
  19. // requested block
  20. var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
  21. if(block == null){
  22. block = window.location.href.match(/[\?|\&]block=(.+)/)
  23. }
  24. if(block != null){
  25. $(".tripal-data-block").hide().filter("#" + block[1] + "-tripal-data-block").show();
  26. }
  27. }
  28. };
  29. })(jQuery);
  30. </script>
  31. <div id="tripal_<?php print $node_type?>_content" class="tripal-contents">
  32. <table id="tripal-contents-table">
  33. <tr class="tripal-contents-table-tr">
  34. <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
  35. print $content['tripal_toc']['#value'] ?>
  36. <!-- Resource Links CCK elements --><?php
  37. if(property_exists($node, 'field_resource_links')) {
  38. for($i = 0; $i < count($node->field_resource_links); $i++){
  39. if($node->field_resource_links[$i]['value']){
  40. $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
  41. <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
  42. }
  43. }
  44. } ?>
  45. </td>
  46. <td class="tripal-contents-table-td-data" align="left" width="100%">
  47. <!-- Resource Blocks CCK elements --> <?php
  48. if (property_exists($node, 'field_resource_titles')) {
  49. for ($i = 0; $i < count($node->field_resource_titles); $i++){
  50. if ($node->field_resource_titles[$i]['value']){ ?>
  51. <div id="tripal_<?php print $node_type?>-resource_<?php print $i?>-box" class="tripal_<?php print $node_type?>-info-box tripal-info-box">
  52. <div class="tripal_<?php print $node_type?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
  53. <?php print $node->field_resource_blocks[$i]['value']; ?>
  54. </div> <?php
  55. }
  56. }
  57. }?>
  58. <!-- Let modules add more content -->
  59. <?php
  60. foreach ($content as $key => $values) {
  61. if (array_key_exists('#value', $values) and $key != 'tripal_toc') {
  62. print $content[$key]['#value'];
  63. }
  64. }
  65. ?>
  66. </td>
  67. </tr>
  68. </table>
  69. </div>