working-with-domain-access-module

Installation steps:

1. Download and install the Domain Access module using this link.
2. Then paste the following in your settings.php file :

/**
 * Add the domain module setup routine.
 */
include DRUPAL_ROOT . '/sites/all/modules/domain/settings.inc';

3. Then rebuild the permission.

Domain Access:

i. Enable “Domain Access” in the modules section.

38

ii. Navigate to “Admin->Structure->Domains”.

iii. There will be multiple tabs, but for now we will navigate to the “Domain List” tab. There we will find “localhost” as the only domain listed.

1

iv. There we will find an option labelled as “Create Domain”. Then we click on that link to create a new domain with the “Domain” value as “testdomain1.com” and “Name” value as “test domain1” and then we leave all other fields as it is and then we click on “Save Domain Record” button.

2

v. After saving the new domain record we will see a domain with the name “test domain1” appears in the “Domain List”.

3

vi. Navigate to the windows “hosts” file located at “Windows/system32/drivers/etc/hosts” and then define an alias as “127.0.0.1 testdomain1.com” and then we restart the server.

vii. Now we navigate to our “Domain List” and there we will notice that the active domain is highlighted. For now we see that “localhost” is highlighted.

4
viii. Now we open http://testdomain1.com/<your-drupal-installation-directory&gt; in a separate window. After that we login as administrator and then we navigate to “Domian List”, there we would see that “test domain1” is highlighted.

5

ix. Then we proceed to create a node of basic page content type. When we create a node, we will get an option as “Domain access options” on the node creation page.

6

Here we have two options:
i. Send to all affiliates: After checking this option, the content will be published on all domains.
ii. Publish To: Here we will have all the domain names listed. We can select the domain, where we want this node to be published.

Note: We need to avoid selecting “Send to all affiliates” option if we need to publish a node to particular domains. But the nodes will be shown to the administrator, even when logged in from a domain in which a node is restricted.

We had created a node named as “Test basic page 1”, and then we had set “localhost” in the “Publish To” section and we had unchecked “Send to all affiliates”, as a result the page is not shown up on “testdomain1.com” and it is shown up on “localhost”. When we try to access this page via URL also on “testdomain1.com” we will be redirected to access denied page.

7

8

x. In the “Domain List” we have an option as “DEFAULT”.

9

We can set our default domain here. Our default domain is the one, which will be used for all requests that fail to resolve to a registered domain.

Domain Alias

i. Enable “Domain Alias” in the modules section.

ii. Navigate to the windows “hosts” file located at “Windows/system32/drivers/etc/hosts” and then define an alias as “127.0.0.1 testdomain2.com” and then we restart the server.

iii. Then navigate to “Domain List” and edit the domain named as “test domain1”.

11

iv. Then we will find the “Aliases” tab. Click on that tab.

12

v. Then we could find that in the “Registered aliases for testdomain1.com” section there are no aliases recorded for this domain. Then in the “Add new aliases” section we add an alias as “testdomain2.com”.

13

vi. Now when we open http://testdomain2.com/<your-drupal-installation-directory&gt;, we will notice that we are automatically redirected to “http://testdomain1.com/<your-drupal-installation-directory&gt;. Hence we had successfully created an alias for http://testdomain1.com/<your-drupal-installation-directory&gt;.

Note: We cannot have a domain, present in our “Domain List” in the alias section.

Domain Configuration

i. Enable “Domain Configuration” in the modules section.

ii. Then navigate to “Domain List” and edit the domain named as “test domain1”.

iii. Then we will find the “SETTINGS” tab. Click on that tab.

14

iv. In the “SETTINGS” page we have the complete site settings for that particular domain:
i. Site Configuration.

15
ii. Administrative Theme.

16
iii. Time zone Settings.

17
iv. Performance.

18
v. Maintenance mode.

19
vi. Menu Settings.

20
vii. Content type menu Settings.

21

Domain Content

i. Enable ‘Domain Content’ in the modules section.

ii. Then in the admin panel we would see a tab labelled as “Affiliated Content” would appear.

22

iii. The “Affiliated Content” section shows all the affiliate sites, whose content we can edit. We can click on the affiliate site’s link to view the content that has been assigned to it.

Here we have two site’s that is localhost and testdomain1.com, after clicking on any of which we can see the content that has been assigned to it, and we can also edit the content.

23

iv. Then we create a node of basic page content type, and in its domain access option, we unchecked “Send to all affiliates”, and in “Publish to” section we only select localhost.

24

v. Then go to “Affiliated content” section and we open “localhost” to view the content assigned to it. We could see that “Test Basic Page 1” is listed.

25

vi. Then we open “testdomain1.com” to view the content assigned to it. We could see that there is no content listed.

26

Domain Source

i. Enable ‘Domain Source’ in the modules section.

ii. After that we create a node of basic page content type. Then on the node creation page we would get an option labelled as “Source Domain”.

27

iii. In the “Source domain” section we would get a drop down box in which all the domains that we had defined would be listed along with the “Active Domain” option.

In our case we will have “Active Domain”, “localhost” and “test domain1” in the drop down list.

iv. When we define a source domain for a node, and then if we open that node from any other domain other than the source domain defined for that node, then we will automatically be redirected to the source domain. If we are logged in as admin from any other domain, other than the source domain defined for that node, and then we edit that node, then we would be redirected to the source domain, and then we would be required to login as admin again, and after that we would be able to edit that node.

In our case we had defined a node of basic page content type and we gave the source domain for that node as “test domain1”. The we open “localhost” and after that we open the node defined, then we notice that we are automatically redirected to “testdomain1.com”, and then we are able to view that node.

v. When we select “Active Domain”, then the current domain in which we are working would be used as the source domain.

Domain Strict

i. Enable ‘Domain Strict’ in the modules section.

ii. Then we create a node of basic page content type, and in its domain access option, we unchecked “Send to all affiliates”, and in “Publish to” section we select both “localhost” and “test domain1”. After doing this the node so defined can be viewed on “testdomain1.com” and “localhost”.

iii. Then we create two users, “testuser1” and “testuser2” from the admin side and on the user creation page, in the “Domain Access” section we select “localhost” for testuser1, and “test domain1” for testuser2.

Domain access settings for testuser1.

28

Domain access settings for testuser2.

29

In the “Domain Access” section we select the affiliates to which a user belongs to. This is used to grant editing permissions for users with the “edit domain content” permission.

The users that we had created can successfully log in on any domain. This should not be misunderstood that, if we had selected “localhost” for testuser1 then he would only be able to login on localhost domain. The “testuser1” can also login on “testdomain1.com”.

We can restrict the users to be able to login to only particular domain, which I will discuss later.

iv. After we enable “Domain Strict”, then the node for which “Send to all affiliates” is unchecked, then that node could not be viewed by anonymous users.

v. “Domain Strict” allows only the registered users to view a node after they login, on the basis of the domain(affiliate selected for the user at the time of user creation) a user belongs to. It forces users to be assigned to a domain in order to view content on a domain.

Here we had created a node which is published to both “localhost” and “test domain1”. And after that we had created two users, “testuser1” which belongs to “localhost” and “testuser2” which belongs to “test domain1”.

Now when “testuser1” logs in on “localhost” then the “testuser1” would be able to view the that node. And when “testuser2” logs in on “localhost” then the “testuser2” wont be able to view that node. And vice-versa happens on “testdomain1.com” for “testuser1” and “testuser2”.

Domain Theme

i Install a theme and just “enable” it. We can find many Drupal responsive themes available for free on this site http://www.devsaran.com/free-drupal-theme.

ii. Enable ‘Domain Theme’ in the modules section.

iii. Then navigate to “Domain List” and edit the domain named as “test domain1”.

iv. Then we will find the “THEME” tab on the domain edit page. Click on that tab.

30

v. In the theme page we find that “Bartik” is the default theme selected for “testdomain1.com”.

31

vi. Since I had installed “Nexus theme”, I select that theme and then set it as domain theme for “testdomain1.com”.

32

vii. Then we open http://testdomain1.com/<your-drupal-installation-directory&gt;, we will find we will have a different theme for it, and we have “Bartik” for http://localhost/<your-drupal-installation-directory&gt;.

33

Domain Bonus

i. Download and install the “Domain Bonus” module from here. Then Enable ‘Domain Bonus’ in the modules section.

ii. Previously we had created two users, “testuser1” who belonged to “localhost” and “testuser2” which belonged to “test domain1” respectively.

iii. The “Domain Bonus” module restricts the users from logging in on any other domain to which they don’t belong.

In our case “testuser1” is successfully able to login on “localhost”, but “testuser1” is restricted from logging in on “test domain1”.

Blocks provided by Domain Access module

1. Domain access server information : Displays the active domain’s server information.

34

2. Domain switcher : Provides an interface to switch between domains on a single click. The active domain will be highlighted.

35

3. Domain alias switcher : Provides an interface to switch between domains on a single click. The active domain will be highlighted.

36

4. Domain list navigator : Provides a drop down interface to switch between domains. The active domain will be selected.

37

Advertisements