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;