tripal_contact_properties.tpl.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // expand the contact to include the properties.
  3. $contact = $variables['node']->contact;
  4. $contact = chado_expand_var($contact, 'table', 'contactprop', ['return_array' => 1]);
  5. $contactprops = $contact->contactprop;
  6. // put the properties in an array so we can remove the contact_description property
  7. $properties = [];
  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 = chado_expand_var($property, 'field', 'contactprop.value');
  14. $properties[] = $property;
  15. }
  16. }
  17. }
  18. if (count($properties) > 0) { ?>
  19. <div class="tripal_contact-data-block-desc tripal-data-block-desc">
  20. Additional information about this contact:
  21. </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 = ['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 = [];
  31. // add the properties as individual rows
  32. foreach ($properties as $property) {
  33. $rows[] = [
  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 = [
  43. 'header' => $headers,
  44. 'rows' => $rows,
  45. 'attributes' => [
  46. 'id' => 'tripal_contact-table-properties',
  47. 'class' => 'tripal-data-table',
  48. ],
  49. 'sticky' => FALSE,
  50. 'caption' => '',
  51. 'colgroups' => [],
  52. 'empty' => '',
  53. ];
  54. // once we have our table array structure defined, we call Drupal's theme_table()
  55. // function to generate the table.
  56. print theme_table($table);
  57. }