You are here

Learn how to use Domain Access module in 10 easy steps

There are times when you want to make want to make a site which when access through a particular place will show particular content or specifically speaking when accessed from different domains will show different in this blog i am going to tell you about the domain module which can be used to show different content to the user according to the URL referred.
Before reading I would recommend to read this.
Here are the steps

1. Install Drupal as you do normally

2. Create the required sub domains that you want and point them all to the same Drupal root (Primary site)

Add the following in your /etc/httpd/conf.d/vhost.conf file

  1. NameVirtualHost *:80
  3. <VirtualHost *:80>
  4. ServerAdmin
  5. ServerName
  6. ServerAlias
  7. DocumentRoot /srv/www/
  8. ErrorLog /srv/www/
  9. CustomLog /srv/www/ combined
  10. <Directory /srv/www/abc/public_html/>
  11. AllowOverride All
  12. Order allow,deny
  13. Allow from all
  14. </Directory>
  15. </VirtualHost>
  17. <VirtualHost *:80>
  18. ServerAdmin
  19. ServerName
  20. ServerAlias
  21. DocumentRoot /srv/www/
  22. ErrorLog /srv/www/
  23. CustomLog /srv/www/ combined
  24. <Directory /srv/www/abc/public_html/>
  25. AllowOverride All
  26. Order allow,deny
  27. Allow from all
  28. </Directory>
  29. </VirtualHost>

3. Make sure that these domains open up in the browser and your website is accessible by all these domains.

4. Install the domain module

5. Before you enable the module add the following lines in settings.php file.

  1. /**
  2. * Add the domain module setup routine.
  3. */
  4. include DRUPAL_ROOT . '/sites/all/modules/domain/';

6. Now enable the module and go to: Administration > Structure > Domains to make sure there are no error messages

7. Go to admin/reports/status/rebuild to Rebuild the permissions.

8. Your first domain will become default domain and all existing nodes will be assigned to your primary domain.

9. Now go to Administration > Structure > Domains to create one more domain using same settings as primary domain. At this point if you create a new user and assign it to then that user created node will be assigned to mumbai domain

10. If you want each domain to have their own moderator i.e. role who will edit all the nodes of a particular content type then change the permissions as mentioned below.
Go to :Administration > People > Permissions >Roles and select edit permissions for moderator role

Under Domain Access
Check this permission: "Client: Edit any content on assigned domains" (do for all content types)

Under Node
Uncheck this permission: "Client: Edit any content"

Using the permissions so far user of any domain/affiliate can view all the nodes across all the domains.

And that is it.

How to show the nodes of a particular affiliate separately in the view.

1. Install Domain views module

2. Add the field "Domain ID" in the view, the same field can be added as a filter and exposed to the user to change.