Ok, I think I've officially read everything and watched every tutorial, but am still flailing.

SUMMARY

The basic problem is that I'm trying to use an entity reference field on the "attached-to" node as the source for my EVA view's contextual filter. It seems that using a token-based EVA argument is the standard way to do this kind of thing, but the tokens keep getting replaced with the referenced entity's title instead of its id. (I could use the title field--it works, I tried it-- but since the title isn't guaranteed unique that's obviously not a great solution.)

OBJECTIVE

The underlying use-case is that pages can include a slideshow. For various reasons (which aren't very flexible, so I'm hoping to make it work), we've opted to do this via an entity reference field to a slideshow custom entity, then use an EVA view to select and render the appropriate slides.

DETAILS

The "schema"

A node bundle -- 'page'
... with an attached entity reference field -- 'field_referenced_slideshow_id'
... which points to a custom entity -- 'slideshow'
... by way of the slideshow entity's primary key field -- 'ssid' (I've confirmed this is set in the entity's hook_entity_info: ... 'entity keys' => array('id' => 'ssid', ... ).

So, node.field_referenced_slideshow >> slideshow.ssid >> [EVA: token argument -> contextual filter] >> slides

(The slideshow entity has a multi-value entity reference field that points to a "slideshow_item" content type, but that's extraneous here, or at least I think it should be.)

The view

I have an EVA view that correctly (in Views preview) selects the appropriate slideshow content based upon a 'ssid' value supplied to a contextual filter.

Just in case, an export of the view: https://gist.github.com/anonymous/6506834.

'Entity Content Settings':

  • Entity Type: Node
  • Bundles: Page
  • Arguments: (token) -> [node:field-slideshow-reference] (I have also tried [node:field_slideshow_reference])

Argument token testing:

No matter which token I use, Views generates the query by replacing the token with the referenced slideshow entity's title, instead of its id field.

Given a 'slideshow' entity with ssid=1 and title="test slideshow", here's what I get from $view->query->query()->getArguments() using various tokens:

  • token: [node:field-slideshow-reference] >> Replaced value: "test slideshow"
  • token: [node:field-slideshow-reference:0] >> Replaced value: "test slideshow"
  • token: [node:field_slideshow_reference] >> Replaced value: "test slideshow"
  • token: [node:field_slideshow_reference:0] >> Replaced value: "test slideshow"

CONCLUSION

It seems like it has to be possible to get the entity id value from an entity reference field using the EVA UI (and without adding php in the filter). Isn't this a fairly standard use-case for EVA?
Is there an "extended entity tokens" module I need to install?
I'll stop offering my thoughts now, as they're clearly not getting me anywhere.
Thanks as always!

Comments

jaskho’s picture

Issue summary: View changes

Confirmed entity pk definition

jlporter’s picture

Project: EVA: Entity Views Attachment » Token
Version: 7.x-1.2 » 7.x-1.5
Component: User interface » Code
Category: Support request » Bug report

Not using eva but using tokens in rules to send an email with token values. There is a token display mode but that doesn't change how it renders in this context.

I also tried - and _ type of tokens to no avail.

Moving to tokens queue.