From 829f16d0076e9be7eda253a413c08f0d8b58ddbe Mon Sep 17 00:00:00 2001 From: tadean <51835841+tadean@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:01:16 -0700 Subject: [PATCH] Fixes #3030 Link Publication Titles to Node. (#3031) --- .../custom/az_publication/az_publication.module | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/custom/az_publication/az_publication.module b/modules/custom/az_publication/az_publication.module index cfad3fb47b..ff41c52a92 100644 --- a/modules/custom/az_publication/az_publication.module +++ b/modules/custom/az_publication/az_publication.module @@ -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;