tripal_project_base.tpl.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. $node = $variables['node'];
  3. $project = $variables['node']->project;
  4. // get the project description. The first iteration of the project
  5. // module incorrectly stored the project description in the Drupal
  6. // node->body field. It should have been in the chado.projectprop
  7. // table. Therefore, for backwards compatibility, we will check if the
  8. // node->body is empty and if not we'll use that instead. Otherwise,
  9. // we'll pull from the projectprop table.
  10. $project_description = '';
  11. if ($node->body) {
  12. $project_description = $node->body;
  13. }
  14. else {
  15. // expand the project to include the properties.
  16. $project = tripal_core_expand_chado_vars($project,'table','projectprop', array('return_array' => 1));
  17. $projectprops = $project->projectprop;
  18. foreach ($projectprops as $property) {
  19. if($property->type_id->name == 'project_description') {
  20. $property = tripal_core_expand_chado_vars($property,'field','projectprop.value');
  21. $project_description = $property->value;
  22. }
  23. }
  24. // if there is no project_description property then see if
  25. // there is anything in the project.description field. This field is only 255
  26. // characters and isn't large enough for some project description, which is why
  27. // the description is stored as a property. But if we have no property then
  28. // use the field
  29. if (!$project_description) {
  30. // we expect the project.description field will one day get changed to
  31. // a text field so, we'll expand it now so that the template won't break if the field ever does change.
  32. tripal_core_expand_chado_vars($project,'field','project.description');
  33. $project_description = $project->description;
  34. }
  35. }
  36. ?>
  37. <div id="tripal_project-base-box" class="tripal_project-info-box tripal-info-box">
  38. <div class="tripal_project-info-box-title tripal-info-box-title">Project Details</div>
  39. <div class="tripal_project-info-box-desc tripal-info-box-desc"></div>
  40. <table id="tripal_project-table-base" class="tripal_project-table tripal-table tripal-table-vert">
  41. <tr class="tripal_project-table-even-row tripal-table-even-row">
  42. <th>Project Name</th>
  43. <td><?php print $project->name; ?></td>
  44. </tr>
  45. <tr class="tripal_project-table-odd-row tripal-table-odd-row">
  46. <th>Description</th>
  47. <td><?php print $project_description?></td>
  48. </tr>
  49. </table>
  50. </div>