We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9873
    • 14 Posts
    Hi,

    I’m totally new to ModX and was wondering if it’s possible to have three websites which all feed off the same database? I’m thinking of creating an information portal and there would be three related websites which I’d want to share the same database.
    However, all three of the sites wouldn’t use all the information available in the database. For example site 1 may have items A, B and C, site 2 would have B, C and D and site 3 would have A, C, D and E.

    If it’s possible, I’m guessing that the database itself would be ’attached’ to one of the sites for maintainence etc. but how would you be able to update all information in the database if the site it’s attached to doesn’t use all of it. Using the above example again, how would you be able to update item D if the database is attached to site 1 - it doesn’t utilise item D itself.
    Hope this makes sence??!

    Thanks in advance for your replies.

    Best regards,
    Tony.
      • 13577
      • 302 Posts
      I think there are really two questions here:

      1) Can multiple sites share the same database?
      2) Can multiple sites share the same data?

      Those are very different questions. The answer to #1 is absolutely. Within the confines of your hosting specs (database size), you can run multiple sites from one database simply by giving each site a different table name prefix. You can run a variety of other apps (bulletin boards come to mind) in the same database the same way.

      Running multiple sites from the same DATA is a bit harder question. There are certain config settings held within the database that will make this difficult, i.e. s base url. Now I’ve never actually attempted this, but it seems reasonable to think that there would be headaches a plenty. But this is a big community. Maybe someone else has done it!
        Standard Disclaimer
        I could be totally wrong.
        • 17145
        • 1 Posts
        I also have a similar issue.

        I have 2 websites to manage, a football website and a complete media websites but i will want to know if i can have the media website displaying news from the football category from same database as the football website without giving it different database prefix and also without having to post each news item twice.

        I hope i have made myself clear.
          • 31837
          • 59 Posts
          Hi guys,

          Now, although I’m not a modx pro, I would say there are two answers to this problem.

          Firstly, yes, you can access databases from multiple sites. That depends on your server settings (eg, if they are hosted on different boxes), othewise, it’s not too big of an issue.

          However.

          the modx settings are stored IN the database, eg, of where paths are, such as these two fields:

          ’rb_base_dir’, ’/this/is/you/actualy/phsical hard drive/location/modx/’
          ’filemanager_path’, ’/this/is/you/actualy/phsical hard drive/location/modx/’

          However, I’m sure if you want to spend a bit of time changing a couple things, you may get it working.

          But see what others around here say. I’m sure it’s a possibility.

          You may probably have to change some of the settings and hard code them in at config.inc or something.

          Tony, I understand what you are saying. But I don’t know if it can be done. That would probably mean modify, the database and the code too a little.

          I’ve successfully run the multiple shops code in OSCommerce, (ok, not modx, but still) running 5 shops from one database. But it was a big project.

          the other thing I would suggest is pulling the data straight from the database, not using the standard modx method of *content* using snippets and stuff.

          cheers.