From f322a7c93a85e901fdba393d6a8891ef11cd6e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Wed, 18 Aug 2021 22:16:50 -0400 Subject: [PATCH] Iterate through authors as getting value directly only gets the first Ref #108 --- web/modules/custom/geo_citation/geo_citation.module | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/modules/custom/geo_citation/geo_citation.module b/web/modules/custom/geo_citation/geo_citation.module index 740eb8a..3745a5e 100644 --- a/web/modules/custom/geo_citation/geo_citation.module +++ b/web/modules/custom/geo_citation/geo_citation.module @@ -75,7 +75,12 @@ function geo_citation_pseudo_field($entity) { return $markup; } - $authors = isset($entity->field_authors->entity) ? $entity->field_authors->entity->title->value : ''; + $authors = ''; + foreach ($entity->field_authors as $i => $author) { + // @TODO replace this with https://packagist.org/packages/agaric/oxford-comma + $authors .= ($i > 0) ? ', ' : ''; + $authors .= isset($author->entity) ? $author->entity->title->value : ''; + } $date = $entity->field_publication_date->value; $year = substr($date, 0, 4); $title = $entity->title->value;