tripal_project_properties.tpl.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // expand the project to include the properties.
  3. $project = $variables['node']->project;
  4. $project = chado_expand_var($project,'table', 'projectprop', array('return_array' => 1));
  5. $projectprops = $project->projectprop;
  6. // put the properties in an array so we can remove the project_description property
  7. $properties = array();
  8. if ($projectprops) {
  9. foreach ($projectprops as $property) {
  10. // we want to keep all properties but the project_description as that
  11. // property is shown on the base template page.
  12. if($property->type_id->name != 'Project Description') {
  13. $property = chado_expand_var($property,'field','projectprop.value');
  14. $properties[] = $property;
  15. }
  16. }
  17. }
  18. if (count($properties) > 0) { ?>
  19. <div class="tripal_project-data-block-desc tripal-data-block-desc">Additional information about this project:</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_project-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. }