How can you refer to content ID from underlying URL while adding a new node? 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!
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:

https://www.drupal.org/node/2905210#comment-12238299

Thank you again for your help! :)