tripal_stock_properties.tpl.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
  3. //
  4. // Purpose: Provide layout and content for stock properties. This includes all
  5. // fields in the stockprop table with the stock_id of the current stock
  6. // supplemented with extra details for the type to provide human-readable
  7. // output
  8. //
  9. // Note: This template controls the layout/content for the default stock node
  10. // template (node-chado_stock.tpl.php) and the Stock Properties Block
  11. //
  12. // Variables Available:
  13. // - $node: a standard object which contains all the fields associated with
  14. // nodes including nid, type, title, taxonomy. It also includes stock
  15. // specific fields such as stock_name, uniquename, stock_type, synonyms,
  16. // properties, db_references, object_relationships, subject_relationships,
  17. // organism, etc.
  18. // - $node->properties: an array of stock property objects where each object
  19. // the following fields: stockprop_id, type_id, type, value, rank
  20. // and includes synonyms
  21. // NOTE: For a full listing of fields available in the node object the
  22. // print_r $node line below or install the Drupal Devel module which
  23. // provides an extra tab at the top of the node page labelled Devel
  24. ?>
  25. <?php
  26. //uncomment this line to see a full listing of the fields avail. to $node
  27. //print '<pre>'.print_r($node,TRUE).'</pre>';
  28. ?>
  29. <?php
  30. $properties = $node->stock->stockprop;
  31. if (!$properties) {
  32. $properties = array();
  33. } elseif (!is_array($properties)) {
  34. $properties = array($properties);
  35. }
  36. ?>
  37. <div id="tripal_stock-properties-box" class="tripal_stock-info-box tripal-info-box">
  38. <div class="tripal_stock-info-box-title tripal-info-box-title">Properties</div>
  39. <div class="tripal_stock-info-box-desc tripal-info-box-desc">Properties for the stock '<?php print $node->stock->name ?>' include:</div>
  40. <?php if(count($properties) > 0){ ?>
  41. <table class="tripal_stock-table tripal-table tripal-table-horz">
  42. <tr><th>Type</th><th>Value</th></tr>
  43. <?php // iterate through each property
  44. $i = 0;
  45. foreach ($properties as $result){
  46. $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
  47. if($i % 2 == 0 ){
  48. $class = 'tripal_stock-table-odd-row tripal-table-even-row';
  49. }
  50. print '<tr class="'.$class.'"><td>'.$result->type_id->name.'</td><td>'.$result->value.'</td></tr>';
  51. $i++;
  52. } ?>
  53. </table>
  54. <?php } else {
  55. print '<b>There are no properties for the current stock.</b>';
  56. } ?>
  57. </div>