tripal_pub_teaser.tpl.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. $node = $variables['node'];
  3. $pub = $variables['node']->pub;
  4. // get the citation
  5. $values = [
  6. 'pub_id' => $pub->pub_id,
  7. 'type_id' => [
  8. 'name' => 'Citation',
  9. ],
  10. ];
  11. $citation = chado_generate_var('pubprop', $values);
  12. $citation = chado_expand_var($citation, 'field', 'pubprop.value');
  13. // get the abstract
  14. $values = [
  15. 'pub_id' => $pub->pub_id,
  16. 'type_id' => [
  17. 'name' => 'Abstract',
  18. ],
  19. ];
  20. $abstract = chado_generate_var('pubprop', $values);
  21. $abstract = chado_expand_var($abstract, 'field', 'pubprop.value');
  22. $abstract_text = '';
  23. if ($abstract) {
  24. $abstract_text = htmlspecialchars($abstract->value);
  25. $abstract_text = substr($abstract_text, 0, 450);
  26. $abstract_text .= "... " . l("[more]", "node/$node->nid");
  27. }
  28. $teaser_text = "<ul id=\"tripal-pub-teaser-citation\"><li>" . $citation->value . "</li></ul>" . $abstract_text;
  29. ?>
  30. <div class="tripal_pub-teaser tripal-teaser">
  31. <div class="tripal-pub-teaser-title tripal-teaser-title"><?php
  32. print l($pub->title, "node/$node->nid", ['html' => TRUE]); ?>
  33. </div>
  34. <div class="tripal-pub-teaser-text tripal-teaser-text"><?php
  35. print $teaser_text; ?>
  36. </div>
  37. </div>