Problem/Motivation
We've been successfully using the SDC Display module for a while and it worked great; however, we've recently faced an issue where we haven't been able to implement the link to the node rendered with SDC Display.
In a traditional templates-based approach, a few extra variables like the entity object, URL, etc are available; however, this is not the case for SDC Display.
Steps to reproduce
1. Create the SDC with an entity URL field.
2. Enable SDC Display for the node display.
3. Try to map the node URL to the display.
Expected: able to pass in the entity URL in the component.
Actual: it's not possible.
Proposed resolution
Two possible approaches:
1. Implement mapping some basic variables like entity ID, revision ID, entity type, entity object (as slot?), URL, title, display mode... you name it.
2. Go with tokens instead.
Issue fork sdc_display-3462243
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pcambraComment #3
e0ipsoI think the tokens road is the my preferred, but I could go both ways.
Comment #5
attiks commentedRan into the same problem, needed the URL of the entity when using the display.
Comment #7
pcambraComment #8
grumpydev74As a workaround, you could still add a field to host those values on the node (hide them in the node form) and use hook_node_view to alter the fields values and set the required values (the hook has access to the node entity).
But I’m agree, it would be great to have those values available out of the box. As well, it would be a good idea to allow pseudo fields to be used in the SDC display mapping.
Comment #9
pcambraTaking a look a this, we can easily fall into entities that do not have canonical URLs
I think it is ok to pass id, entity_type and bundle, but we should remove URL and leave that for #3377609: Implement Token Replacements
Comment #10
pcambraComment #12
pcambraThanks all!