tripal_stock_collections.tpl.php

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

File

legacy/tripal_stock/theme/templates/tripal_stock_collections.tpl.php
View source
  1. <?php
  2. $stock = $variables['node']->stock;
  3. // expand the stock object to include the stockcollections associated with this stock
  4. $options = array('return_array' => 1);
  5. $stock = chado_expand_var($stock, 'table', 'stockcollection_stock', $options);
  6. $collections = $stock->stockcollection_stock;
  7. if (count($collections) > 0) {?>
  8. <div class="tripal_stock-data-block-desc tripal-data-block-desc">This stock is found in the following collections.</div> <?php
  9. // the $headers array is an array of fields to use as the colum headers.
  10. // additional documentation can be found here
  11. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  12. // This table for the analysis has a vertical header (down the first column)
  13. // so we do not provide headers here, but specify them in the $rows array below.
  14. $headers = array('Collection Name', 'Type', 'Contact');
  15. // the $rows array contains an array of rows where each row is an array
  16. // of values for each column of the table in that row. Additional documentation
  17. // can be found here:
  18. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  19. $rows = array();
  20. foreach ($collections as $collection_stock){
  21. // get the stock collection details
  22. $collection = $collection_stock->stockcollection_id;
  23. $contact = $collection->contact_id;
  24. $cname = $collection->name;
  25. if (property_exists($collection, 'nid')) {
  26. $cname = l($collection->name, "node/" . $collection->nid, array('attributes' => array('target' => '_blank')));
  27. }
  28. $rows[] = array(
  29. $cname,
  30. ucwords(preg_replace('/_/', ' ', $collection->type_id->name)),
  31. $contact->name,
  32. );
  33. }
  34. // the $table array contains the headers and rows array as well as other
  35. // options for controlling the display of the table. Additional
  36. // documentation can be found here:
  37. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  38. $table = array(
  39. 'header' => $headers,
  40. 'rows' => $rows,
  41. 'attributes' => array(
  42. 'id' => 'tripal_stock-table-synonyms',
  43. 'class' => 'tripal-data-table'
  44. ),
  45. 'sticky' => FALSE,
  46. 'caption' => '',
  47. 'colgroups' => array(),
  48. 'empty' => '',
  49. );
  50. // once we have our table array structure defined, we call Drupal's theme_table()
  51. // function to generate the table.
  52. print theme_table($table);
  53. }