tripal_feature_properties.tpl.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. dpm($node);
  26. ?>
  27. <?php
  28. $feature = $node->feature;
  29. $feature = tripal_core_expand_chado_vars($feature,'table','featureprop');
  30. $properties = $feature->featureprop;
  31. if (!$properties) {
  32. $properties = array();
  33. } elseif (!is_array($properties)) {
  34. $properties = array($properties);
  35. }
  36. ?>
  37. <div id="tripal_feature-properties-box" class="tripal_feature-info-box tripal-info-box">
  38. <div class="tripal_feature-info-box-title tripal-info-box-title">Properties</div>
  39. <div class="tripal_feature-info-box-desc tripal-info-box-desc">Properties for the feature '<?php print $node->feature->name ?>' include:</div>
  40. <?php if(count($properties) > 0){ ?>
  41. <table class="tripal_feature-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_feature-table-odd-row tripal-table-odd-row';
  47. if($i % 2 == 0 ){
  48. $class = 'tripal_feature-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 '<div class="tripal-no-results">There are no properties for the current feature.</div>';
  56. } ?>
  57. </div>