Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Followup to #2010898: Use tokens for entity selection view arguments:
* Use token for entity selection view arguments
* Add a token that sometimes is empty (and is not the last if that matters)
* Have that argument "display all if empty"
This makes views display nothing instead of all items.
Comment | File | Size | Author |
---|---|---|---|
#2 | entityreference-2830703-2-Empty-token-break.patch | 1.09 KB | geek-merlin |
|
Comments
Comment #2
geek-merlinPatch flying in that fixes this issue for me.
It extends the "pass 0" logic for empty entity IDs to all other empty args.
(I'm not too happy with this, but i don't expect the underlying views question will ever be fixed in D7.)
(Quite some people consider anything that views does after such a long time a feature not a bug ;-)
Comment #3
MustangGB CreditAttribution: MustangGB commentedIs this related to, or a duplicate of #2815863: Contextual filter values of "" don't trigger "When the filter value is NOT available"?
Comment #4
cmseasy CreditAttribution: cmseasy commentedPatch worked for me, thanks
Comment #5
joelpittetThe solution in #2 seems like it needs more thourough debug into the root cause. Setting all the empty values to 0, should be done in views if it's really correct way forward.
Comment #6
david.qdoscc CreditAttribution: david.qdoscc commentedFor me this patch still didn't address the issue with [node:nid] resulting in an error Notice: Undefined property: stdClass::$nid in node_tokens()
I did get around this by using [current-page:url:unaliased:args:value:N] instead of [node:nid] to pass the ID when editing existing content but pass a 0 when adding new content.
Comment #7
PanchoComment #8
marksmith CreditAttribution: marksmith commentedSolution #6 works if (A) entity reference field widget type is (multiple value) select list, but not with (B) ER multiple value autocomplete field (with Add more button). (B) is preferred in some cases where selected value order is important.