What token should I use with ECA Views

Created on 23 February 2023, almost 2 years ago
Updated 4 March 2023, almost 2 years ago

Problem/Motivation

I would like to loop into Paragraph items to display value from a field inside paragraph. I don't know how to do that with ECA action, so, I go with ECA Views. But with all possible Token, nothing is show at all.

Steps to reproduce

  • Create Views to display data I want. (My data I want to retrieved is in Taxonomy which is a field in Paragraph and this paragraph is an entity reference in main content.)
  • Use ECA to display data I get from Views. Tried many different Token from "Browse available tokens" without success. No data is shown at all. Only one token is show which is [entity:field_name:entity] but it's just some kind of pointer, not the data in the content.

*** I use ECA Views from ECA Guide and modified it to match my setup.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

1.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @abx
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Your view needs to be built to receive one or many contextual arguments to filter your entities you're going to receive from that view. If that works as expected, then you can use the Views: Execute query action to receive the results. To do that, you need to provide the value for the view filter in the Arguments field.

    Once that action is being executed, it returns a list of entities. You can then loop through those, examples on how that can be done are available in the library, e.g. Views or Multi value field loop

  • Status changed to Postponed: needs info almost 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Still trying to understand how ECA Views works. I think that with ECA Views, I can grab the result from Views into Token for me to work on it. But it looks like I misunderstand it.

    For testing purpose, here is what I did :
    1. Create a new content type with taxonomy.
    2. Use Views to show the result I want.
    3. Use ECA to display message of Token from "Views Execution Query"
    4. What I got here is taxonomy target_id, not the text I saw with Views result.

    Below is Token from ECA:

    - nid: - value: '26767' uuid: - value: 898e1b37-4170-4ca6-93e9-7d641a91e81e vid: - value: '55281' langcode: - value: en type: - target_id: test_content revision_timestamp: - value: '1677766452' revision_uid: - target_id: '1' revision_log: - value: 'Updated the Title and Long Text fields' status: - value: '1' uid: - target_id: '1' title: - value: 'TEST TITLE' created: - value: '1677692028' changed: - value: '1677766452' promote: - value: '1' sticky: - value: '0' default_langcode: - value: '1' revision_default: - value: '1' revision_translation_affected: - value: '1' path: - langcode: en menu_link: { } field_long_text: - value: 'TEST LONG TEXT BODY' field_test_date: - value: '2023-03-15T04:11:11' field_test_taxonomy: - target_id: '407' - nid: - value: '26595' uuid: - value: 2a831eff-578a-4006-91b6-5c5128bccd78 vid: - value: '54976' langcode: - value: en type: - target_id: test_content revision_timestamp: - value: '1666284100' revision_uid: - target_id: '1' revision_log: - value: 'Updated the Value2 field' status: - value: '1' uid: - target_id: '1' title: - value: 'test 1' created: - value: '1666283961' changed: - value: '1666284100' promote: - value: '1' sticky: - value: '0' default_langcode: - value: '1' revision_default: - value: '1' revision_translation_affected: - value: '1' path: - langcode: en menu_link: { } field_long_text: { } field_test_date: { } field_test_taxonomy: { }

    Below is what I see in Views:

    TEST TITLE
    TEST LONG TEXT BODY
    Wed, 03/15/2023 - 11:11
    Test Tag 1

    If apply this into my original plan which is I need to get a data from a field inside Paragraph inside node content. The event will be about that node (Presave, I think.) With ECA Views, I will need more time to set it up since the data for that node is already in there.

    If what I understand now is correct, then, what should I do to make this work?

  • Status changed to Active almost 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    If you work with a node that has a list of paragraphs in a field, then you already have a list by just working with the field value from that node.

    If you need to grab a list of entities otherwise, then the views execute action is what you need.

    In both cases, what you receive is a token containing a list. You should not expect to just print that list and all is done. It's a list of entities, and you can use ECA actions and conditions to build loops to work with each entity in that list. Examples of such loops are linked in my comment #2 above.

    Note 1: from views, you always receive a list of entities no matter what configuration you've done for display, formatting or fields in that view.

    Note 2: from multi-value fields, you always receive a list of items, but we can't tell exactly what data type the list items will be, that depends on the field type. If it's an entity reference field (like with paragraphs) you usually get a list of target IDs, which requires you to load the respective entities with the appropriate action from ECA.

  • Status changed to Fixed almost 2 years ago
  • Thank you for your explanation. The answer is clear and I will go to ECA in the node instead of Views.

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

Production build 0.71.5 2024