In Drupal 7, I have a content type with an entity reference field. When adding new content of this type, an entity reference view filters the available options.

A contextual filter on this entity reference view should check whether the data matches against the node ID from URL being viewed while adding the new content.

I'm not sure whether I understand correctly how Drupal is supposed to work here, as everything I've tried gives no results, unless I manually enter test data in which case it works fine.

Let's say a user is on page site.com/?q=node/75, then adds content. The new URL is site.com/?q=node/75#overlay=%3Fq%3Dnode%252Fadd%252Fcontenttype.

The contextual filter is set for "When the filter is not available" to "Provide default value" of type "Content ID from URL". This returns zero results, even though I could manually provide the filter value and it would show the actual results.

Is this because the "Content ID from URL" is coming from the underlying (originating) URL instead of the overlay new content part of the path? Or is there some other issue?

How is it possible to filter contextually against the content ID of the original page from which a user adds new content? If it could be done by passing arguments to the contextual filter with a token from the entity reference field, that would be fine too, however so far I have tried with current page node and more and run into the same problem, it does not filter any of the appropriate results.

Thank you for your help!

  • 1
    entity prepopulate module is what you need
    – pinueve
    Commented Aug 28, 2017 at 21:37
  • Thank you... That seems to depend on adding the argument to the URL, which would take somehow rewriting all links to add this type of content? Also I'm trying it and so far I don't have it accepting URL arguments, instead it just goes back to "Add content" page. Commented Aug 28, 2017 at 22:42
  • I just added the solution I found below. I don't really see what role entity prepopulate would play but maybe it could do something similar. Commented Aug 29, 2017 at 3:25

1 Answer 1


It seems that the node in the original link is only for the source page, not for the page in question when Drupal determines which data to pass into the contextual filter. Instead, I wound up creating a new URL path pattern and filtering on the basis of that structure. Then I could add token-using links to various pages, with the contextual filter picking up the pattern of those paths.

You can find a full write-up at the Drupal forums:


Thank you again for your help! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.