We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16868
    • 24 Posts
    I’ve been hunting high and low for a solution but so far haven’t had any luck, so here goes.

    Working with Modx Revo btw.

    My client company has split personalities and wants two websites with separate domains/designs but that access/display the same database of products. Also, while 90% of the database entries will be common to both sites, there should be some way to allow some entries to NOT show on one site or the other.

    So far I’ve thought of a few possibilities but none seem to go all the way.

    1. Run two different templates, choose template based on domain (siteusa.com runs template A, siteintl.com runs template B), and both templates read the same resources. Problems: No clue how to do it, and also not sure how to hide certain resources from one site when desired.

    2. Use localization. Problem: Solutions I’ve seen for this have a set of resources for each locale (seems obvious--different lang. content would have to be stores apart).

    3. Use Revo Contexts. Again, seems only to create two sets of resources.

    4. I’m guessing there’s some solution I’m overlooking totally. Hoping.

    Any help would be much appreciated!
      • 16868
      • 24 Posts
      ***Edit: These don’t solve my problem after all, keep going down...***

      Damn typical, after searching for two days I finally post my problem, then within 10 minutes find...

      http://modxcms.com/forums/index.php/topic,31725.0.html

      and

      http://svn.modxcms.com/docs/display/revolution/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains

      I previously wrote them off since they’re from way back and I just assumed they wouldn’t be worth much. Anyway let me keep trying for a bit, I’ll post again if needed.
        • 25663 MODX Staff
        • 12,272 Posts
        Just use two prefixes in one database. Beware of scaling issues though.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 16868
          • 24 Posts
          Thanks for your reply! However I don’t think I was clear enough.

          Don’t different prefixes just give the appearance of different databases in the end? I’ve got a couple of small sites running like that already...

          Really what I need is something like one set of resources in Modx, and two categories of templates, where a category gets applied depending on what URL the end user is coming in on. So, if they type in www.site-usa.com they’ll see the content presented with the USA templates, and if they come in on www.site-intl.com they’ll see the same content but presented with the INTL templates.

          An additional hitch is that certain amount of content should only show on one site or the other, and this should be easily specified.

          So far I have some ideas:

          -I know I can get one Modx install to work with more than one domain.

          -I know it’s easy to detect what domain the end user is coming in on. (parse-url() snippet)

          -I think it might be possible to assign USA, INTL or Both when creating a resource by using a TV--or maybe I could just get users to keep the resources well categorized in the manager, shouldn’t be much trouble.

          -I think I might want to detect the domain, then assign the appropriate template, but I think this might not even be possible. Each resource seems pretty tied to a template...

          Any replies are much appreciated, even if it’s just to say you’re crazy give up haha. I won’t though.
            • 19368
            • 40 Posts
            I would use a TV hooked to a snippet that looked at the URL to determine which site it is.

            Then, in the template use chunks for your code, loading the chunk based on the URL - driven by the TV.

            That way, to make a change, simply editing a chunk and it propagates through the site via the template.

            Does that make sense?
              • 16868
              • 24 Posts
              If I do that would the template info get cached? I started going down that road but thought it might be resource heavy since it’s figuring out what template to show every pageview. If I’m wrong I’ll get back to trying that.

              My other idea just now was have to contexts both linked to the same database, maybe have the resources themselves in a third context to keep things neat. God I have no idea what I’m doing haha, ok back to reading up!

              Thanks!
                • 4172
                • 5,888 Posts
                I think you can try it with 3 contexts.

                web - which holds your site-structure and all resources for both domains.

                domain A - same site-structure but with some special resources in it.
                domain B - the same for second domain.

                you will need some special snippets to get the resources from web-context and them of your context you’re in together.
                and maybe a plugin which switches the template.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 16868
                  • 24 Posts
                  Thanks for your input! Bruno I like your idea but special snippets and plugins... haha no idea where to start with that action. Microbe your idea gave me another idea, which so far is working.

                  I have one template that just contains one snippet. The snippet starts by grabing the domain name, and then uses that info to decide on a chunk to return, the template html being in held in the chunk.

                  The thing is, to get those chunks into the game I’m passing them to the snippet as parameters, then returning one of them to the template. Seems rather inefficient! Add to that the snippet has to be uncached so it doesn’t get stuck on one template, I feel like the server’s going to be doing a lot of unnecessary running around.

                  Maybe it’s not a big deal?

                  ***Edit***
                  Ok the real reason multiple contexts is out is that I have 400+ resources that have a complex organization, and scattered among that organization are 20~30 resources that are unique to one site or the other so if I went with multiple contexts I’d have a nightmare on my hands getting the unique resources to appear in their proper places along side the resources common to both sites.

                  ***Edit 2***
                  I guess I can get the template chunks directly from the db, I’ll work on that.