1

I understand sharing databases/tables is frowned upon as a practice, however, I need to share users and some nodes between two websites. What are the alternatives and what are the pros and cons of the most common strategies?

To give slightly more detail. I need to create a website for "staff and authenticated users" that is separate to a main site that the public anonymously accesses. On this secondary site there will be forums and chat functionality moderated by admins for both sites. I would like to avoid having the admin users re-log in when they are managing the second site.

I also need to allow for some future integration where some "logged in" user content appears on the main site.

Are the two alternatives for doing this only,

  • Make one giant single site
  • Share databases

or is there some other way?

4
  • 1
    This is something domain access can solve
    – Kevin
    Commented Dec 19, 2016 at 1:01
  • 1
    you mean this: drupal.org/project/domain ? I am a little concerned that it is still in Alpha for drupal 8. But yes, it is the kind of thing I am looking for. Are there any more mature/stable solutions for drupal 8 yet?
    – tanbog
    Commented Dec 19, 2016 at 1:07
  • You can also get that module on github github.com/agentrickard/domain for the lastest updated version. Commented Dec 19, 2016 at 3:56
  • Having certain parts available only for authenticated users should be relatively easy to implement using permissions and possibly some route alters and node/term access hooks. Do you really need two sites or just avoid that some parts like the forum overview pages and forum nodes are inaccessible to anonymous users?
    – Berdir
    Commented Dec 19, 2016 at 19:37

1 Answer 1

2

Sharing users can be done by setting up OpenAuth or something like it.

Sharing nodes can be done using views database connector this tool will let you pull data from a table in another database. To make it work for pulling in nodes, create a MYSQL view (https://dev.mysql.com/doc/refman/5.7/en/create-view.html) that holds the node data you need to share out. The views connector will be able to read in that table allowing you to create views from your other server without having to duplicate the content. You can filter on any field in the table. This set up works well for a 1 to Many Content server environment where you don't want to have a new copy of every node on every new install. https://www.drupal.org/project/views_database_connector

You can also create a module that pulls data from the other database and present it any way you want.

If you are fine duplicating the content you may want to explore Drupal aggregation it's easy to set up and can all be done through the UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.