We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3677
    • 130 Posts
    I’m hoping to use ModX contexts to manage many domains inside the same install. I’ve got two domains resolving as separate contexts in my installation.
    Now I need to figure out how I could access a resource that is created under ContextA from a page that is loading in ContextB.

    For example I have set site_start on Context B to a home page which uses a common template. I’d like to load the same css style sheet that I am loading for Context A.
    The problem is no matter how I setup the path it is always going to be a subpage of Context B domain. ex: http://contextb.com/master.css
    This doesn’t work because the master.css resource document exists under context A only. ex: htttp://contexta.com/master.css

    Any ideas?


      • 3677
      • 130 Posts
      After digging some more I found out about Symlinks which might work for this, except that it appears they do not currently work across contexts.

      I think I have a work-around though if I use external files and include calls.

      ModX Document = Master.css - Uses an Include snippet to load an external css file. Still able to assign a template and use tvs inside the external css file.
      All I have to do is duplicate the Master.css document inside of each context.

      While I do have to have multiple instances of the resource doc, in reality each context is loading a single css file thanks to the same include statement in each document. This way I can use tvs inside of the css file to style based on each site context.

      -Brian
        • 9496
        • 113 Posts
        It seems that sharing across contexts is good from the core perspective (element/plug-in creation etc.) but from the page/include/front end standpoint is a little tricky. Im doing the same thing (except with 4 unique domains). The problem was that within each context the base urls & directories are independent from the install directory so the paths are localized to that domain.

        Instead of having multiple asset directories and such (which kind of defeats the purpose imho), for each context I created a new context setting to override the default url of the asset directory.

        So under context, I added a new context setting key called "assets_url" and just filled it in with my url to my main install directory (eg:http://www.foo1.com/assets/) and then I call it like this within my template chunk.

        <link rel="StyleSheet" href="[[++assets_url]]css/global.css" type="text/css">


        I’m not sure if I could use a manager_base_dir or something like that (tv variable perhaps?) within the context setting so its not hardcoded to the url but Ive only begun playing around with revo and Im still getting my sea legs. I guess my logic is that its just rewriting the assets directory in the config file so I only have to worry about one asset directory. You could also probably accomplish this with a apache rewrite directive of some kind but im not sure if thats the most effective to go about it.


          • 18373 ☆ A M B ☆
          • 3,141 Posts
          I think fatknuckle’s response is currently considered the best way to go with any common files you need to use.

          It would be nice to allow symlinks across contexts though, perhaps you can file a feature request for it at http://bugs.modx.com?
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.