tripal_contact_properties.tpl.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // expand the contact to include the properties.
  3. $contact = $variables['node']->contact;
  4. $contact = tripal_core_expand_chado_vars($contact,'table', 'contactprop', array('return_array' => 1));
  5. $contactprops = $contact->contactprop;
  6. // put the properties in an array so we can remove the contact_description property
  7. $properties = array();
  8. if ($contactprops) {
  9. foreach ($contactprops as $property) {
  10. // we want to keep all properties but the contact_description as that
  11. // property is shown on the base template page.
  12. if($property->type_id->name != 'contact_description') {
  13. $property = tripal_core_expand_chado_vars($property,'field','contactprop.value');
  14. $properties[] = $property;
  15. }
  16. }
  17. }
  18. if (count($properties) > 0) { ?>
  19. <div id="tripal_contact-properties-box" class="tripal_contact-info-box tripal-info-box">
  20. <div class="tripal_contact-info-box-title tripal-info-box-title">More Details</div>
  21. <div class="tripal_contact-info-box-desc tripal-info-box-desc">Additional information about this contact:</div><?php
  22. // the $headers array is an array of fields to use as the colum headers.
  23. // additional documentation can be found here
  24. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  25. $headers = array('Property Name', 'Value');
  26. // the $rows array contains an array of rows where each row is an array
  27. // of values for each column of the table in that row. Additional documentation
  28. // can be found here:
  29. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  30. $rows = array();
  31. // add the properties as individual rows
  32. foreach ($properties as $property) {
  33. $rows[] = array(
  34. ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  35. $property->value
  36. );
  37. }
  38. // the $table array contains the headers and rows array as well as other
  39. // options for controlling the display of the table. Additional
  40. // documentation can be found here:
  41. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  42. $table = array(
  43. 'header' => $headers,
  44. 'rows' => $rows,
  45. 'attributes' => array(
  46. 'id' => 'tripal_contact-table-properties',
  47. ),
  48. 'sticky' => FALSE,
  49. 'caption' => '',
  50. 'colgroups' => array(),
  51. 'empty' => '',
  52. );
  53. // once we have our table array structure defined, we call Drupal's theme_table()
  54. // function to generate the table.
  55. print theme_table($table); ?>
  56. </div> <?php
  57. }