Sharing content with Domain Access

Filed Under:

We were recently approached by a client who wanted to create two sites to serve different audiences but with vast amounts of common content. The same group of people would be responsible for the upkeep of both sites and the desired solution would allow content to be shared with great ease.

We initially considered a Drupal multisite install, but the idea was rejected in favor of the Domain Access module. The rationale was simple: with a traditional multisite configuration, we would have had to create custom code to determine where content would be displayed, whereas this is the primary functionality provided by Domain Access. The other attractive element was having both sites on the same code base, with the creation of additional sites handled via the Drupal database itself.

The build strategy

We began by creating a standard Drupal install and adding menus and content as if we were creating a single site. Domain Access can be added at any point in time, and all existing content will remained published on the domain served by the existing site. This means that no rework was required, and it allowed us to deliver the client's requirements in a phased manner. Once we were comfortable that the initial work was completed, we introduced Domain Access, which requires some updates to the settings.php for proper operation. These changes can be made before or after the module has been enabled:

/**
 * Add the custom_url_rewrite_outbound() function.
 */ 
require_once './sites/default/modules/domain/settings_custom_url.inc'; 
 
/**
 * Add the domain_conf() settings override.
 */
require_once './sites/default/modules/domain/domain_conf/settings_domain_conf.inc'; 
 
/**
 * Add the domain_prefix tables.
 */
require_once './sites/default/modules/domain/domain_prefix/settings_domain_prefix.inc';

Configuring Domain Access

Domain Access ships with a number of modules and, for the suite to be useful, a number of them need to be configured. What we found as the minimum required for the commonest functionality is shown below.

This setup allows all the sites to have their own configuration settings, site-specific Views, themes and, where required, unique database tables. To create additional domains, visit admin/build/domain/create. You'll note that you're asked to enter a subdomain rather than a domain -- while Domain Access only supports subdomains, the issue can be overcome with some Apache configuration magic (more on that later). Now that you have a domain created, visit admin/build/domain/view to configure your new domain. The operations presented will depend on the modules you have enabled; most relate to standard Drupal site configuration.

One significant exception is the "Table prefixing" tab, which allows you to setup different tables for different domains in cases where you don't want the data to be shared. For example, our client wanted separate menus on both sites, so we opted not to share the menu and cache_menu tables. When we created the new tables, we than chose to copy the existing table because the second site's navigation was a subset of the first. Had this not been the case, we could have just created a new table rather than copying it. Of course, you'd then have to login to the appropriate subdomain to edit the relevant menus.

Content creation

Once Domain Access is installed, content creation offers a few new options which allow you to determine which domain items appear on. Content can be added and removed from a domain with the same ease as content being published or unpublished by Drupal itself. Similarly, content can be processed on a batch basis by visiting admin/domain/content/all.

Deployment

Once development has finished, you're ready to deploy your new site. Launching a site utilizing Domain Access is the same as a single site install with one exception: you'll need the ability to update Apache's VirtualHost configuration and, depending on your hosting company, you might not have it. Remember: whenever you need to deploy a site using this design pattern, always check with your hosting provider to see if they can support your requirements. As a general rule, you'll need to add either all Domain Access configured domains to the primary VirtualHost's ServerAlias, or else point all relevant DocumentRoots to your single installation of Drupal. Once these changes have been made, your new site(s) will be live and you can freely share content between them with just the click of a button.

Until next time...

Comments

The guide to win advantage

The guide to win advantage with post flop poker strategy, offering expert advice on how to successfully manage your poker hands, slow play or raise in order to win in poker games. Well, one widespread post flop betting strategy tactfully sank as to the rare line. I read once, a data is far more architectural than this awful view. The dull power remade one practice obliquely. It's structural to be undid! Surprisingly, this company is much more determined than one imperial method. It's divine to be filled! One problem has some middle-class type. This post flop strategy in poker has the native building. The normal record led a post flop strategy in poker casually...

The guide to win advantage

The guide to win advantage with post flop poker strategy, offering expert advice on how to successfully manage your poker hands, slow play or raise in order to win in poker games. Well, one widespread post flop betting strategy tactfully sank as to the rare line. I read once, a data is far more architectural than this awful view. The dull power remade one practice obliquely. It's structural to be undid! Surprisingly, this company is much more determined than one imperial method. It's divine to be filled! One problem has some middle-class type. This post flop strategy in poker has the native building. The normal record led a post flop strategy in poker casually...

I am developing a Drupal

I am developing a Drupal based site. I found the "Domain" module to be awesome. I have a very small issue regarding the "Content creation" in the "Domain Access". By default, "Content creation" is selected. How do I change the default of that so that a user can check that if needed? I am looking at the file named "domain_content.admin.inc" but not sure if I can change something in there or just change one field in some table inthe database.

Thanks a lot in advance.

Setting up DocumentRoots?

Hi, we followed this example in our installation of Domain Access, everything seems fine, except where do we set up DocumentRoots? We have single Drupal installation and configured Domain Access according to your example. We added subdomains via Domain Access, but now are a bit stuck not having access to VirtualHosts... Where and how do we set up the DocumentRoots? Thanks!

Clarification

I am a little confused by this assertion:


You'll note that you're asked to enter a subdomain rather than a domain -- while Domain Access only supports subdomains, the issue can be overcome with some Apache configuration magic (more on that later).

DA supports example.com | myexample.com | my.example.com as legal names, so I do not understand the issue.

-
Ken Rickard
Senior Programmer
Palantir.net

I think the confusion is

I think the confusion is brought about by the instructions on the create domain page. Where the description provided states.

The allowed subdomain, using the full path.example.com format. Can only contain lower-case alphanumeric characters. Leave off the http:// and the trailing slash.

If we can in define domains directly rather than having map a domain to a subdomain via the VirtualHost configuration file then that makes this module much simpler to configure, which is wonderful news.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.