tripal_stock_properties.tpl.php

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

File

tripal_stock/theme/templates/tripal_stock_properties.tpl.php
View source
  1. <?php
  2. $stock = $variables['node']->stock;
  3. $options = array('return_array' => 1);
  4. $stock = chado_expand_var($stock, 'table', 'stockprop', $options);
  5. $stockprops = $stock->stockprop;
  6. // the stock synonyms are stored in the stockprop table because we do not have
  7. // a stock_synonym table. Therefore, we don't want to synonyms in the properties
  8. // list as those get shown by the tripal_stock_synonyms.tpl.inc template.
  9. $properties = array();
  10. if ($stockprops) {
  11. foreach ($stockprops as $property) {
  12. // we want to keep all properties but the stock_description as that
  13. // property is shown on the base template page.
  14. if($property->type_id->name != 'synonym' and $property->type_id->name != 'alias') {
  15. $property = chado_expand_var($property,'field','stockprop.value');
  16. $properties[] = $property;
  17. }
  18. }
  19. }
  20. if(count($properties) > 0){
  21. // the $headers array is an array of fields to use as the colum headers.
  22. // additional documentation can be found here
  23. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  24. $headers = array('Property Name', 'Value');
  25. // the $rows array contains an array of rows where each row is an array
  26. // of values for each column of the table in that row. Additional documentation
  27. // can be found here:
  28. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  29. $rows = array();
  30. foreach ($properties as $property){
  31. $property = chado_expand_var($property,'field','stockprop.value');
  32. $rows[] = array(
  33. array('data' => ucfirst(preg_replace('/_/', ' ', $property->type_id->name)), 'width' => '20%'),
  34. urldecode($property->value)
  35. );
  36. }
  37. // the $table array contains the headers and rows array as well as other
  38. // options for controlling the display of the table. Additional
  39. // documentation can be found here:
  40. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  41. $table = array(
  42. 'header' => $headers,
  43. 'rows' => $rows,
  44. 'attributes' => array(
  45. 'id' => 'tripal_stock-table-properties',
  46. 'class' => 'tripal-data-table'
  47. ),
  48. 'sticky' => FALSE,
  49. 'caption' => '',
  50. 'colgroups' => array(),
  51. 'empty' => '',
  52. );
  53. // once we have our table array structure defined, we call Drupal's theme_table()
  54. // function to generate the table.
  55. print theme_table($table);
  56. }