tripal_feature_properties.tpl.php 2.4 KB

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