Document corrected (not assuming a single value field) check for GEO Original term
Ref #10
This commit is contained in:
parent
a984702fc0
commit
d3d09f56ca
1 changed files with 9 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue