How can I have conditional content within page body that is dependent upon the domain? We are planning to use Domain Access to manage 5 different domains that will share content.  The majority of our pages will be shared across all 5 domains and will look identical on each domain. Domain Access makes it trivial to handle this use case. However, on some of the pages, 95% of the content will be identical and 5% of the content will be dependent upon the domain that is serving the page.

One possible solution is to create a unique page for each domain and publish it to the appropriate domain.  Although this works, it is difficult to maintain because we would need to maintain changes to the identical content across 5 unique pages.

Another option would be to embed PHP in the page, such as

shared content for all 5 sites here.

&lt;?php if ($_SERVER['HTTP_HOST'] === 'domain1.example.com') { ?&gt;

domain1 specific content here

&lt;?php } else if ($_SERVER['HTTP_HOST'] === 'domain2.example.com') { ?&gt;

domain2 specific content here

&lt;?php } ?&gt;


Again, this would work, but has several disadvantages.  I am looking for a way to share the identical content across the domains and yet have site specific content within a page in a way that makes it feasible to maintain and easy for content editors (non-technical users) to edit. Does anyone have any suggestions?
The sites module has support for multiple domains and managing content across those domains. 

https://www.drupal.org/project/sites

If you are using the same template file for the page where you are displaying your content, then you can implement the 'hook_site_access()' from the sites module in the template file, and gather the content you desire to display based on the domain name.

In addition, depending on the type of content you are displaying, you might be able to get away with simply using the Views or Context integration from the Sites module, rather than editing your template file manually.

Another option is to use Drupal's taxonomies to classify your content. Then, you could use any of the solutions above (custom code in page template, Views, or Context) to filter only the content which is categorized to be displayed on the domain you are on.

In any case, if you want two different versions of the same page to display on different domains, you will need two different nodes, and they will need to be classified accordingly. I'm not sure if there is any way around maintaining multiple nodes if the content varies by domain. 

However, when the same node is to be displayed on multiple domains, this kind of architecture will allow you to display it only on a specific subset of domains you choose.