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

    I started installing MODx for some domains. My structure is as follows:

    - root (MODx web context) --> mysite.com
    - subdomains/members --> members.mysite.com
    - core

    Changing the structure was no problem, because of the really nice documentation, but I have one problem I couldn't solve on my own:

    The regular behavior of the web-context is:

    - Show all pages including unpublished pages, if the user is an admin (and logged in, of course).

    The behavior of the context, let's call it "members" is:

    - If I try to view a page in the frontend while I'm logged in as admin while the page is OFFLINE (site_status of the context = No), I only can view the error page.
    - If I try to view a UNPUBLISHED page in the frontend (again, logged in as admin) and the page / context ist ONLINE, I get redirected to the "unauthorized_page"

    I already followed the suggestions from https://forums.modx.com/thread/103279/using-context-new-context-redirect-to-default-context

    Any ideas?

    Thanks for the help!
    Simon


    This question has been answered by BobRay. See the first response.

    [ed. note: simonh last edited this post 5 years, 9 months ago.]
    • discuss.answer
      • 3749
      • 24,544 Posts
      If I try to view a page in the frontend while I'm logged in as admin while the page is OFFLINE (site_status of the context = No), I only can view the error page.

      Logged in *where* as the admin?

      If you're logged in to the Manager and view the front end, you're still logged into the 'mgr' context, but you're not logged in to the front-end context unless you explicitly log in there. Your status when not logged in to the front-end context is somewhat ambiguous.

      What happens if the context is offline, you go to edit the page in the Manager, and then click on the "View" button at the upper right?

      TBH, I'm not sure what the expected behavior is for Manager users viewing pages of a site that's off-line.

      If nothing else works, you could leave the site on-line and create a custom snippet that would redirect most users (but not you) to the error page when a certain System Setting (created by you - you could call it maintenance_mode) was set.

        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
        • 54933
        • 4 Posts
        Hi Bob,

        Thank you for your answer.

        MODx created context-permissons with the "Context" policy and the Admin group, with an authority of 9999.
        After a few tests I changed this to the Admin policy and the Admin group with an authority of 0.

        I tried to mirror the web context as good as I could.

        So I was logged in as admin in web/mgr/mycontext, I guess.

        Quote from: BobRay at Mar 07, 2019, 09:55 PM

        What happens if the context is offline, you go to edit the page in the Manager, and then click on the "View" button at the upper right?

        I'll get redirected to the site_unavailable_page.

        Best,
        Simon

        EDIT: I installed the Login Extra to be sure, that I'm logged in to the context in the frontend.
        I switched the context to on, logged in and turned the context off - after this it works as expected. It seems like the session doesn't include subdomains (without having a look at it). [ed. note: simonh last edited this post 5 years, 9 months ago.]
          • 3749
          • 24,544 Posts
          Did you include &contexts in your Login tag?
            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
            • 54933
            • 4 Posts
            Quote from: BobRay at Mar 08, 2019, 05:11 PM
            Did you include &contexts in your Login tag?

            Not this time.

            I changed session_cookie_domain for the context (members.mysite.com) to mysite.com and now everything works like expected.

            Thank you, Bob!
              • 3749
              • 24,544 Posts
              I should have thought of that. wink

              FYI, if users will be going back and forth between contexts, you can use something like this in the Login tag to log them in to all contexts at once:

              &contexts=`web,context1,context2,context3`


              Also turning on the allow_forward_across_contexts System Setting is sometimes necessary.
                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
                • 54933
                • 4 Posts
                Great, I'm sure I'll need this as soon as I've finished the migration!

                Thanks again smiley