Display nodes from multiple domains

How to override the global domain access for a views display

Domain Access is a great Drupal module for setting acces to content (nodes) depending on the (sub-)domain.

It has great integration with Views but there a few caveats though, one of them is that it can be quite hard to make a Views display that shows content from multiple domains. There are two options that I know of:

  1. Add a Special Page Request on the Domain Settings page
  2. Disable SQL rewriting

Both have their own merits.

Add a Special Page Request on the Domain Settings page

Image of the Special Page Request textares on the Domain Access settings page

You can override your domain access control for specific pages by adding them to the Special Page Request textarea on the settings page of Domain Access (/admin/structure/domain/settings).
All pages listed will override the access control set by Domain Access, this can be very useful for a homepage for instance that has an overview of all news items published to all (sub-)domains.


The disadvantage is that it is a on/off solution, domain access control is not available for the complete page. Your menu for instance will reflect that; all menu items from all domains will show. Also you will only be able to show content from all domains, a selection of domains will not be possible.

Disable SQL rewriting

There is another option, that will give you more control, but also more responsibility.

Image of the Views advanced query setting to disable SQL rewriting

No node_access checks

A standard Views option is to disable SQL rewriting. You can do that under Advanced, Query settings. There are several options here, but it’s the first we’re interested in. By disabling the SQL rewriting you will disable all node_access checks. As Domain Access is “just” a node access module, this will disable the access checks for all nodes displayed in this View. This comes with a risk, though, which is why a warning is displayed when enabling this option. Because it disables node_acess checks visitors might be able to see nodes for which they have no permission. A very simple example is non-published nodes. In a regular setup anonymous visitors will not have the permission to see unpublished nodes, but disabling SQL rewriting will let them view unpublished nodes as well.

Filters to the rescue

To remedy this there is a simple solution: just add a filter so only published nodes will be shown. Add fiters for all not permitted options and you will be fine.

And because you can use filters you are also able to make a selection of the domains you want your nodes to come from. Simply add a filter for Domain Access: Domain ID and select the domains that are relevant and you’re done.

Another issue with this solution could come from the fact that it will also disable implementations of hook_query_alter() found in contrib modules. As I have no experience with this, I invite you to let me know what the implications are. For a “straightforward” news overview, like a news archive for Participe Delft I made, this is not really an issue. But your mileage may vary.