I have created a rule to email some fields after a node is created.

Most fields are displayed correctly in the emails except for those that are terms in a vocabulary.

Example Content:
  Create New Content of Car
  Manufacturer of Car: Ford, GM, or Chrysler (terms in the vocabulary manufacturer)

Example Rule:
  action "Send mail" Subject:  A new [node:field-manufacturer] Car.

The replacement token is not returning a value and displaying an error:

Warning: Illegal offset type in _entity_token_get_token() (line 144 of /var/www/html/drupal-7.0/sites/all/modules/entity/entity_token.tokens.inc).

Does anyone have a way of displaying the correct vocabulary term in a rule?

CommentFileSizeAuthor
#5 entity_term_token.patch971 bytesfago
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Itangalo’s picture

Category: support » bug
fago’s picture

Title: Using Taxonomy in Rule » Using Taxonomy term tokens
Project: Rules » Entity API
Version: 7.x-2.0-beta1 » 7.x-1.x-dev
Component: Rules Engine » Core integration

I guess you should use the term name by using [node:field-manufacturer:name]

worldlinemine’s picture

When using modules such as auto_nodetitle when they attempt to use the token associated with a field they are not properly capturing the syntax ie.:
[node:field-manufacturer] vs [node:field-manufacturer:name]

I am also seeing a similar issue in looking at the token through the devel module (the token for a taxonomy appears blank).

But I have confirmed that by using the indicated syntax it is properly making use of the token and exposing its value.

This leads me to the question: Is there a need to document how the use of tokens has changed or if this is already documented is there a need to share this information with module developers who are utilizing entities/tokens?

waverate’s picture

Fantastic.

Syntax at #2 is the solution.

How does this solution get back to the Rules module so that the Replacement Patterns can be updated?

fago’s picture

Status: Active » Needs review
FileSize
971 bytes

We need to fix it, so it works without :name too. Attached patch should do so, please test.

Jerome F’s picture

I tried to use this patch (#5) with Automatic Nodetitles module. The string [node:field-deal-destination-city] is still printed as is, as plain text instead of the term name. Perhaps because I use internationalisation.
[node:field-deal-destination-city:i18n-name] works ok
I come from this issue http://drupal.org/node/1149400 marked as duplicate

fago’s picture

Status: Needs review » Fixed

or, maybe you were trying a multiple field? see #1058856: Entity tokens not created for multi-value fields

Anyway, I tested it and it seem to work fine. Thus, committed.

fago’s picture

Component: Core integration » Entity tokens
artatac’s picture

Status: Fixed » Active

tested using latest dev, ran update.php and flushed caches - still getting

Notice: Undefined index: label in entity_token_token_info_alter() (line 54 of D:\xampp\htdocs\schoolog04\sites\all\modules\entity\entity_token.tokens.inc).
Notice: Undefined index: label in entity_token_token_info_alter() (line 59 of D:\xampp\htdocs\schoolog04\sites\all\modules\entity\entity_token.tokens.inc).
Notice: Undefined index: label in entity_token_token_info_alter() (line 54 of D:\xampp\htdocs\schoolog04\sites\all\modules\entity\entity_token.tokens.inc).
Notice: Undefined index: label in entity_token_token_info_alter() (line 59 of D:\xampp\htdocs\schoolog04\sites\all\modules\entity\entity_token.tokens.inc).
fago’s picture

Status: Active » Fixed

ad #9: If that's not something that happens with term tokens, please open another issues. How can one reproduce this?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.