tripal_library_properties.tpl.php

  1. 2.x tripal_library/theme/templates/tripal_library_properties.tpl.php
  2. 3.x legacy/tripal_library/theme/templates/tripal_library_properties.tpl.php
1 theme call to tripal_library_properties.tpl.php
tripal_library_node_view in tripal_library/includes/tripal_library.chado_node.inc
Implements hook_node_view(). Acts on all content types

File

tripal_library/theme/templates/tripal_library_properties.tpl.php
View source
  1. <?php
  2. $library = $variables['node']->library;
  3. $options = array('return_array' => 1);
  4. $library = chado_expand_var($library, 'table', 'libraryprop', $options);
  5. $props = $library->libraryprop;
  6. // iterate through the properties and remove the 'library_description' as it is
  7. // already displayed on the base template.
  8. $properties = array();
  9. foreach ($props as $prop) {
  10. if ($prop->type_id->name == 'Library Description') {
  11. continue;
  12. }
  13. $properties[] = $prop;
  14. }
  15. if(count($properties) > 0){
  16. // the $headers array is an array of fields to use as the colum headers.
  17. // additional documentation can be found here
  18. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  19. $headers = array('Property Name', 'Value');
  20. // the $rows array contains an array of rows where each row is an array
  21. // of values for each column of the table in that row. Additional documentation
  22. // can be found here:
  23. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  24. $rows = array();
  25. foreach ($properties as $property){
  26. $property = chado_expand_var($property,'field','libraryprop.value');
  27. $rows[] = array(
  28. ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
  29. urldecode($property->value)
  30. );
  31. }
  32. // the $table array contains the headers and rows array as well as other
  33. // options for controlling the display of the table. Additional
  34. // documentation can be found here:
  35. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  36. $table = array(
  37. 'header' => $headers,
  38. 'rows' => $rows,
  39. 'attributes' => array(
  40. 'id' => 'tripal_library-table-properties',
  41. 'class' => 'tripal-data-table'
  42. ),
  43. 'sticky' => FALSE,
  44. 'caption' => '',
  45. 'colgroups' => array(),
  46. 'empty' => '',
  47. );
  48. // once we have our table array structure defined, we call Drupal's theme_table()
  49. // function to generate the table.
  50. print theme_table($table);
  51. }