tripal_contact_base.tpl.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. $contact = $variables['node']->contact; ?>
  3. <div class="tripal_contact-data-block-desc tripal-data-block-desc"></div> <?php
  4. // the $headers array is an array of fields to use as the colum headers.
  5. // additional documentation can be found here
  6. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  7. // This table for the contact has a vertical header (down the first column)
  8. // so we do not provide headers here, but specify them in the $rows array below.
  9. $headers = [];
  10. // the $rows array contains an array of rows where each row is an array
  11. // of values for each column of the table in that row. Additional documentation
  12. // can be found here:
  13. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  14. $rows = [];
  15. // Contact Name row
  16. $rows[] = [
  17. [
  18. 'data' => 'Name',
  19. 'header' => TRUE,
  20. 'width' => '20%',
  21. ],
  22. $contact->name,
  23. ];
  24. // Contact Type row
  25. $rows[] = [
  26. [
  27. 'data' => 'Type',
  28. 'header' => TRUE,
  29. ],
  30. $contact->type_id->name,
  31. ];
  32. // allow site admins to see the contact ID
  33. if (user_access('view ids')) {
  34. // Pub ID
  35. $rows[] = [
  36. [
  37. 'data' => 'Contact ID',
  38. 'header' => TRUE,
  39. 'class' => 'tripal-site-admin-only-table-row',
  40. ],
  41. [
  42. 'data' => $contact->contact_id,
  43. 'class' => 'tripal-site-admin-only-table-row',
  44. ],
  45. ];
  46. }
  47. // the $table array contains the headers and rows array as well as other
  48. // options for controlling the display of the table. Additional
  49. // documentation can be found here:
  50. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  51. $table = [
  52. 'header' => $headers,
  53. 'rows' => $rows,
  54. 'attributes' => [
  55. 'id' => 'tripal_contact-table-base',
  56. 'class' => 'tripal-data-table',
  57. ],
  58. 'sticky' => FALSE,
  59. 'caption' => '',
  60. 'colgroups' => [],
  61. 'empty' => '',
  62. ];
  63. // once we have our table array structure defined, we call Drupal's theme_table()
  64. // function to generate the table.
  65. print theme_table($table);
  66. if (property_exists($contact, 'description')) { ?>
  67. <div style="text-align: justify"><?php print $contact->description; ?></div> <?php
  68. } ?>