I originally created an issue in Rules. But I'm not sure if the origin of the problem is from this module instead, so I'm posting it here as well. Any ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wwwjaylee created an issue. See original summary.

jay.lee.bio’s picture

Title: Rules Host Entity Support? » Token support for Rules host entity?

According to drone.ah, apparently the host entity for Rules is a token added by this module (just like a token added by a Field Collection), so I'm changing the title of this issue.

jeroen.b’s picture

tobiasb’s picture

Title: Token support for Rules host entity? » Fix typo ParagraphsItemMetadataController to provide the host-token in Rules
Version: 7.x-1.0-rc4 » 7.x-1.x-dev
Category: Support request » Bug report
Status: Closed (duplicate) » Needs review
FileSize
1.4 KB

I am not really sure if rules token/ token are the same. Because I did not find the host token in token browser but with patch I saw the token in rules token list.

A test rule. Import the code via http://example.com/en/admin/config/workflow/rules/components/import and execute the rule component, enter a Paragraphs-ID and you should see the url of the host entity. (Must be a node)

{ "rules_test" : {
    "LABEL" : "test",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "entity" : { "label" : "entity", "type" : "paragraphs_item" } },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "entity" ], "type" : "paragraphs_item" } },
      { "entity_is_of_type" : { "entity" : [ "entity:host-entity" ], "type" : "node" } }
    ],
    "DO" : [ { "drupal_message" : { "message" : [ "entity:host-entity:url" ] } } ]
  }
}
tobiasb’s picture

Title: Fix typo ParagraphsItemMetadataController to provide the host-token in Rules » Fix typo in ParagraphsItemMetadataController to provide the host-token in Rules
Murz’s picture

Does this patch allow to use tokens in paragraphs_item entity? So in paragraphs_item textarea field I can type something like [paragraphs_item:pp_title] and it replace this token to Paragraphs pp_title field?
Can you provide more usage examples?

tobiasb’s picture

@Murz When the token is visible in the token-tree, then yes.

Murz’s picture

@tobiasb, thanks for reply. I apply this patch, clear site cache, but in token list for paragraphs_item entity I don't see group "Paragraphs" or something similar. Maybe I need to do some additional things for add Paragraphs token group?

tobiasb’s picture

@Murz

I am not sure but I believe this only works with entity_token. Which is part of the entity project/module.

Murz’s picture

Status: Needs review » Reviewed & tested by the community

I review and test this patch, it actually fixes typo error that break token info for paragraph_item entity. So we can apply it to module core.

And about using tokens into paragraph_item entity: they are not displayed on field properties interface, but available via direct usage, here is examples:

[paragraphs_item:archived]
[paragraphs_item:pp_body]
[paragraphs_item:pp_image]
[paragraphs_item:pp_title]
[paragraphs_item:url]
[paragraphs_item:item-id]

So we can write in pp_body field token [paragraphs_item:pp_title] that will be replaced to Paragraphs title text. Module Entity Token must be enabled for this.

delacosta456’s picture

hi
i apply this patch but can't see how to specify the pargrapgh bundle

Any help please

EDIT : after node have been save with fird rule ... when trying to view, or delete the node i have the below message

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=230&op=do StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type paragraphs_item. in entity_extract_ids() (line 7929 of /Applications/MAMP/htdocs/brainrhdgddi/includes/common.inc).

EDIT2: HOWEVER looking in the database paragraphs_item table the item was saved but his bundle was missing..

  • jstoller committed d16391c on 7.x-1.x authored by tobiasb
    Issue #2618716 by tobiasb, Murz, jstoller: Fix typo in...
jstoller’s picture

Status: Reviewed & tested by the community » Fixed

Patch committed to dev with minor text changes.

Status: Fixed » Closed (fixed)

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