We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27614
    • 10 Posts
    Hi. I have a site which can be opened from different domains. For example my site is xxxxx.ru, but also it can be opend from yyyyy.ru. This is made by editing dns zone for yyyyy.ru like this: yyyyy.ru CNAME xxxxx.ru. The question is how to make personal system setting for each http_host, but the recources and web users for each http_host must be loaded from context "web".
      • 3749
      • 24,544 Posts
      System Settings are not designed to be reset during a session. The change won't take effect until after the current user is gone, so I don't think a System Settings is a good choice for what you're doing.

      You could use a $_SESSION variable, but that would be kind of silly since anywhere it would be available, $SERVER['http_host'] would also be available.

      How to handle this depends partly on what you need to do with the http_host information.

      I think your best might be a simple snippet that returns a string based on the http_host setting:

      $output = 'other'
      if ($_SERVER['http_host'] =='yyyy.ru') {
         $output = 'domain1';
      } elseif ($_SERVER['http_host'] === 'xxxx.ru') {
         $output = 'domain1';
      }
      return $output;
      



      Shorter version:

      return $_SERVER['http_host'] === 'yyyy.ru'? 'domain1' : $_SERVER['http_host'] === 'xxxx.ru'? 'domain2' : 'other';
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 27614
        • 10 Posts
        Quote from: BobRay at Aug 16, 2014, 02:32 PM
        System Settings are not designed to be reset during a session. The change won't take effect until after the current user is gone, so I don't think a System Settings is a good choice for what you're doing.

        You could use a $_SESSION variable, but that would be kind of silly since anywhere it would be available, $SERVER['http_host'] would also be available.

        How to handle this depends partly on what you need to do with the http_host information.

        I think your best might be a simple snippet that returns a string based on the http_host setting:

        $output = 'other'
        if ($_SERVER['http_host'] =='yyyy.ru') {
           $output = 'domain1';
        } elseif ($_SERVER['http_host'] === 'xxxx.ru') {
           $output = 'domain1';
        }
        return $output;
        



        Shorter version:

        return $_SERVER['http_host'] === 'yyyy.ru'? 'domain1' : $_SERVER['http_host'] === 'xxxx.ru'? 'domain2' : 'other';


        Actually what i need is to make each domain independent. All pages (resources) and users are the same for each domain but there should be different settings. For example i use for authorization HybridAuth snippet with social networks. It takes ID and secret key for FB from system settings but for each domain these setting are different. I want to make it work like that is different sites but with the same content. I dont have any idea how to make it work but to not make changes in core files.
          • 3749
          • 24,544 Posts
          That's a tough one. If the login/authorization process is the only difference, it's shouldn't be too difficult to customize the Login process based on the http_host using one or more plugins attached to the Login events. For example, you could forward users to the appropriate Login page based on the domain they come in on.

          If there are other differences, it would get more complicated.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting