From 50c5bd435f1528d391effe0c4083badf791d5aed Mon Sep 17 00:00:00 2001 From: argiepiano Date: Thu, 3 Aug 2023 22:10:43 -0600 Subject: [PATCH] Issue #43. Wrap term tokens on if statement to check for taxonomy Fixes #43 --- entity_token.tokens.inc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/entity_token.tokens.inc b/entity_token.tokens.inc index 70caebb..5c04668 100644 --- a/entity_token.tokens.inc +++ b/entity_token.tokens.inc @@ -94,18 +94,20 @@ function entity_token_token_info_alter(&$info) { 'entity-token' => TRUE, ); - // Tokens for type term. - $info['tokens']['term']['parents_all'] = array( - 'name' => 'All parent terms', - 'description' => t('Ancestors of the term, i.e. parent of all above hierarchy levels.'), - 'type' => 'list', - 'entity-token' => TRUE, - ); - $info['tokens']['term']['weight'] = array( - 'name' => 'Weight', - 'description' => t('The weight of the term, which is used for ordering terms during display.'), - 'entity-token' => TRUE, - ); + if (module_exists('taxonomy')) { + // Tokens for type term. + $info['tokens']['term']['parents_all'] = array( + 'name' => 'All parent terms', + 'description' => t('Ancestors of the term, i.e. parent of all above hierarchy levels.'), + 'type' => 'list', + 'entity-token' => TRUE, + ); + $info['tokens']['term']['weight'] = array( + 'name' => 'Weight', + 'description' => t('The weight of the term, which is used for ordering terms during display.'), + 'entity-token' => TRUE, + ); + } // Add types and tokens for all properties of entities that don't have one. $entity_info = entity_get_info();