[Drupal] Simple tutorial of setting multi subdomain with Domain Access module and Views module

1. Set the hosts file.
Open /etc/hosts file, add the code as below for example:

 

# drupal
127.0.0.1   drupal2.39.lan.gz
127.0.0.1   *.drupal2.39.lan.gz

 

2. Set the Virtual Hosts in Apache
Open /opt/lampp/etc/httpd.conf, add the code as below for example:

<VirtualHost *:80>
    <Directory "/media/MyDocuments/xampp/htdocs/drupal-2">
    </Directory>

    DocumentRoot "/media/MyDocuments/xampp/htdocs/drupal-2"
    ServerName drupal2.39.lan.gz
    ServerAlias *.drupal2.39.lan.gz
</VirtualHost>

 

3. Install the views module

 

4. Install the Domain Access module.
here I use the sites/default as a the primary site, so now edit
the sites/default/settings.php, at the end of this file, add the code as below:

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

Please see more details for why to add the code in the INSTALL.txt of Domain Access module.

 

5. Set the subdomain in the website.
Visit the page, http://drupal2.39.lan.gz/admin/build/domain , select the "Create domain
record" tab to create a subdomain, here I create a subdomain as village-1.drupal2.39.lan.gz
for example, so in the Domain field, I insert village-1.drupal2.39.lan.gz , and the Site name
you can insert what you like. And then save it.
Then as the steps above, I create another subdomain village-2.drupal2.39.lan.gz

 

6. In the page http://drupal2.39.lan.gz/admin/build/domain
"Domain node types" fieldset, uncheck all the checkbox for that I hope that all the content
the editors created only display in the suddomain he belongs to. "Domain-specific settings"
fieldset, select the "All domains" radiobox, and then save.

 

7. Set the role of the Users.
Visit the page, http://drupal2.39.lan.gz/admin/user/permissions/2 ,
in the "domain module", check the checkbox as below:

access inactive domains (option)
administer domains
edit domain nodes
publish from assigned domain (option)
publish from default domain (option)

in the "node module", check the checkbox as below:

access content
create TYPE content (TYPE means that any content types in your website)
edit own TYPE content (TYPE means that any content types in your website)
revert revisions (option)
view revisions (option)

That is the option I suggest to set, of course, if you know what is the difference between them,
you can set what you wish. :)

 

8. Add some users.
In the page, http://drupal2.39.lan.gz/admin/user/user/create ,
Add the user, please be aware the "Domain access" fieldset, here you can set the subdomain
which the user belongs to. Here is the example:
editor1, village-1.drupal2.39.lan.gz
editor2, village-2.drupal2.39.lan.gz

 

9. Use views module to set the default page to the subdomain.
In the page, http://drupal2.39.lan.gz/admin/build/views/add , here is an example,
View name: village_page
View type: Node
Then click next
Add display, in the "page settings" fieldset, set the path to "home", please pay attention to
"Filters" fieldset, select the "Domains" in the "Groups", and then select checkbox
the "Domains: Domain ID", in the next step, select the "Current Domain", save.
About how to set the views parameters, please see the details in drupal.org/project/views.

 

10. Set the default page of the subdomain.
In the page, http://drupal2.39.lan.gz/admin/build/domain , click settings of village-1.drupal2.39.lan.gz ,
in the "Site frontpage: " fieldset, insert the page path I set in above step -- that is home, save.
Set that to village-2.drupal2.39.lan.gz in the same way.

 

11. Login editor1 in village-1.drupal2.39.lan.gz
Create some content after login.
Login editor2 in village-2.drupal2.39.lan.gz
Create some content after login.

Then you will find that, that is differece when visiting village-1.drupal2.39.lan.gz and village-2.drupal2.39.lan.gz


That is all of simple set the Domain Access module.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值