diff --git a/web/modules/custom/geo_citation/geo_citation.module b/web/modules/custom/geo_citation/geo_citation.module index ec35b2d..3125819 100644 --- a/web/modules/custom/geo_citation/geo_citation.module +++ b/web/modules/custom/geo_citation/geo_citation.module @@ -63,9 +63,15 @@ function geo_citation_theme($existing, $type, $theme, $path) { */ function geo_citation_pseudo_field($entity) { $markup = ''; - $article_type = $entity->field_article_type->getValue(); - // If it's not a GEO Original article, there's nothing for us to do. - if (!isset($article_type[0]) || $article_type[0]['target_id'] != '303') { + + // This returns a numerically-indexed array of arrays with little in them + // except the taxonomy term 'target_id' as a stringified number. + $article_types = $entity->field_article_type->getValue(); + // This looks for the index matching 'GEO Original' (term ID 303), which will + // often be zero when it's the only selected article type, so we must be sure + // to test for a false identity and not accidentally reject zero. + if (array_search('303', array_column($article_types, 'target_id')) === FALSE) { + // If it's not a GEO Original article, we do not add a citation. return $markup; }