Skip to content

Commit

Permalink
Fixes #3030 Link Publication Titles to Node. (#3031)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadean authored and joeparsons committed Feb 2, 2024
1 parent ef22dbf commit 2ca355d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/custom/az_publication/az_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@ function az_publication_node_view(array &$build, EntityInterface $entity, Entity
$date->{'date-parts'}[] = explode('-', $entity->field_az_accessed_date->value);
$blob->accessed = $date;
}
// By default, provide a link to the node page if nothing else applies.
try {
// Canonical full node should not link to itself.
if ($view_mode !== 'full') {
$has_cover = !empty($entity->field_az_publication_image->target_id);
$has_abstract = !empty($entity->field_az_publication_abstract->value);
$url = Url::fromRoute('entity.node.canonical', ['node' => $entity->id()]);
// Linking to full node if there is an abstract or cover page.
if ($has_cover || $has_abstract) {
$blob->itemlink = $url->toString();
}
}
}
catch (Exception $e) {
}
// Handle link field if available.
if (!empty($entity->field_az_publication_link->uri)) {
$blob->itemlink = $entity->field_az_publication_link->uri;
Expand Down

0 comments on commit 2ca355d

Please sign in to comment.