tripal_project_teaser.tpl.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. Also, the project.descriptin field is only 255
  7. // characters which is not large neough. Therefore, we store the description
  8. // in the chado.projectprop table. For backwards compatibility, we
  9. // will check if the node->body is empty and if not we'll use that instead.
  10. // If there is data in the project.description field then we will use that, but
  11. // if there is data in the projectprop table for a descrtion then that takes
  12. // precedence
  13. $description = '';
  14. if (property_exists($node, 'body')) {
  15. $description = $node->body;
  16. }
  17. if (property_exists($node, 'description')) {
  18. $description = $project->description;
  19. }
  20. else {
  21. $record = [
  22. 'table' => 'project',
  23. 'id' => $project->project_id,
  24. ];
  25. $property = [
  26. 'type_name' => 'Project Description',
  27. 'cv_name' => 'project_property',
  28. ];
  29. $projectprop = chado_get_property($record, $property);
  30. $description = $projectprop->value;
  31. } ?>
  32. <div class="tripal_project-teaser tripal-teaser">
  33. <div class="tripal-project-teaser-title tripal-teaser-title"><?php
  34. print l($node->title, "node/$node->nid", ['html' => TRUE]); ?>
  35. </div>
  36. <div class="tripal-project-teaser-text tripal-teaser-text"><?php
  37. print substr($description, 0, 650);
  38. if (strlen($description) > 650) {
  39. print "... " . l("[more]", "node/$node->nid");
  40. } ?>
  41. </div>
  42. </div>