tripal_contact_properties.tpl.php

  1. 2.x tripal_contact/theme/templates/tripal_contact_properties.tpl.php
  2. 3.x legacy/tripal_contact/theme/templates/tripal_contact_properties.tpl.php
1 theme call to tripal_contact_properties.tpl.php
tripal_contact_node_view in tripal_contact/includes/tripal_contact.chado_node.inc
Implements hook_node_view().

File

tripal_contact/theme/templates/tripal_contact_properties.tpl.php
View source
  1. <?php
  2. // expand the contact to include the properties.
  3. $contact = $variables['node']->contact;
  4. $contact = chado_expand_var($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 = 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">Additional information about this contact:</div><?php
  20. // the $headers array is an array of fields to use as the colum headers.
  21. // additional documentation can be found here
  22. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  23. $headers = array('Property Name', 'Value');
  24. // the $rows array contains an array of rows where each row is an array
  25. // of values for each column of the table in that row. Additional documentation
  26. // can be found here:
  27. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  28. $rows = array();
  29. // add the properties as individual rows
  30. foreach ($properties as $property) {
  31. $rows[] = array(
  32. ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  33. $property->value
  34. );
  35. }
  36. // the $table array contains the headers and rows array as well as other
  37. // options for controlling the display of the table. Additional
  38. // documentation can be found here:
  39. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  40. $table = array(
  41. 'header' => $headers,
  42. 'rows' => $rows,
  43. 'attributes' => array(
  44. 'id' => 'tripal_contact-table-properties',
  45. 'class' => 'tripal-data-table'
  46. ),
  47. 'sticky' => FALSE,
  48. 'caption' => '',
  49. 'colgroups' => array(),
  50. 'empty' => '',
  51. );
  52. // once we have our table array structure defined, we call Drupal's theme_table()
  53. // function to generate the table.
  54. print theme_table($table);
  55. }