Drupal sharing between two websites

I am a farmer with drupal construction sites, but am not sure what is the best way to implement this scenario. I have two domain names mydomain.com and mydomain2.com. I need to have a conten type with some fields in. Ie

ContentType Field - Title Field - Body Field - Picture Field - Price 

I want both sites to use the same data for a custom conten type. Thus, you enter data on one site, and they will be updated on both.

mydomain.com will display the following content type information.

 ContentType Field - Title Field - Body Field - Picture 

mydomain2.com will show all the data.

mydomain.com and mydomain2.com will have a clear look. And each domain can use some different modules. mydomain2.com will use ubercart, but mydomain.com will not.

I would use mutlisite here and somehow shade the tables. Use one instance of drupal and do the rest with the theme? Use functions and context?

Any help would be appreciated.

+4
source share
4 answers

After some research, this may be what I need http://drupal.org/project/domain . An example study can be found at http://drupal.org/node/369398 .

Still wondering if there are other ways to not take this as an answer.

+3
source

You just need to exchange tables between sites.

You can exchange specific tables (best done in logical groups) compared to Drupal 7 installations by adding something like this to the settings.php file:

 $my_db_users = 'drupal_users.shared_'; $my_db_content = 'drupal_content.shared_'; $databases['default']['default'] = array( 'driver' => 'mysql', 'database' => 'defaultdatabase', 'username' => 'databaseuser', 'password' => 'databasepassword', 'host' => '127.0.0.1', 'port' => 3066, 'prefix' => array( 'default' => 'default_', 'users' => $my_db_users, 'sessions' => $my_db_users, 'role' => $my_db_users, 'authmap' => $my_db_users, 'node' => $my_db_content, 'node_revisions' => $my_db_content, 'node_type' => $my_db_content, ), 'collation' => 'utf8_general_ci', ); 

In the above example, we set variables that point to different databases for certain groups of tables. So, in the above example, we need three databases: defaultdatabase , drupal_users and drupal_content .

Then in the array we set the default table prefix 'default' => 'default_', and in it we say: โ€œstore all tables, unless otherwise specified, in defaultdatabase and make their default table prefix _ โ€. We also say: "Store all users, sessions, roles, and user role mappings (authmap) in the drupal_users database with the shared _ table prefix." And finally, we say: "Store all node types, nodes and their changes in the drupal_content database with the shared _ table prefix."

With great power comes great responsibility:

You completely enclose your installation if you do not store logical groups of tables.

What are logical table groups? Well, probably, any table with the node_ prefix in your current installation should probably be moved to a shared database. Most well-structured modules (e.g. node_access) will have their own table name prefixed with something logical. Based on your modules, make sure you keep the table groups in the right place (in the default database for site data or in another database for shared data.)

Add a little bling:

I did a similar installation where users and roles were separated, but NOT authmap. For what purpose?

Well, if you do, you can have the same users and groups through a large network of sites, giving users different permissions on different sites. On one site you can be an editor, but otherwise you would be an author.

+1
source

The domain module looks good (although I have not used it). This may be redundant for your needs.

If you need something very simple, you can create a module that sets the global $custom_theme to hook_init() depending on the domain.

0
source

For me, if this was a critical part of the site, I would create a custom module. There are several tutorials for creating node_types through modules. I like this one .

So you have the basic structure of your data in a user table, and then you can set up a call to display the data to either include a price column or not.

Again, some may see this as too much work, but if you are not familiar with the development of the Drupal module, this is a great way to find out. If you are familiar, this should be quick and easy.

0
source

Source: https://habr.com/ru/post/1298978/


All Articles