We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38127
    • 5 Posts
    I'm trying to create a separate context to hold private information that would be accessed by http://mysite/private. I created a private folder in the web root and created a context with a homre containe and some pages in it per the modx documentation and other references. When I go to http://mysite/private I get my private page. This home page has links to it's subpages using this format [[~id]]. However, when I hover over the links they have http://mysite/index.php?id=10 where 10 is the id of the page. If I click on the link I get a page not found (makes sense!). I did set some of the paramters such as base_url, site_start, and site_url (set this to http://mysite/private) per this article http://www.belafontecode.com/modx-revolution-hosting-multiple-domains/ but it does not work.

    How should I be setting these up. Most of the documentation assumes a second domain as in mysite2.com but not when I'm trying to create another context like a manager.

    How does the manager do it? I notice is has directories for connectors, etc. and appears to somehow start and run it's own web site (note I'm new to web site development, too!).

    How can I accomplish what I want. Any documentation would be appreciated.

    Also, where can I find out more on how Modx handles the manager site - what process does it go through after it finishes index.php. I've been reading the Modx docs and developer section a lot.

    Thank you.
      • 3749
      • 24,544 Posts
      Setting base_url and site_url context settings for the private context with the correct URLs should do it. Did you clear the cache (and maybe your browser cache) after setting them?
        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
        • 38127
        • 5 Posts
        Quote from: BobRay at Jan 03, 2012, 01:37 AM
        Setting base_url and site_url context settings for the private context with the correct URLs should do it. Did you clear the cache (and maybe your browser cache) after setting them?

        No but I just did <G>. I tried another browser and it still did not work. Maybe I have them set wrong. What should these settings be for http://mysite.com/private? Is the base_url / or /private (I've tried both) and I have the site_url as http://mysite.com/private.

        Are you the Bob of the Bob's guides? If so thank you! They have been very, very helpful as I learn Modx. I have done some work with web sites (not much though) and have a coding backgroun and am finding Modx a fantastic system. I looked at some other CMS but none have the ease of creating sites or the abilty to be flexible!

        Thank you.
          • 3749
          • 24,544 Posts
          I am. Thanks for the kinds words. I'm not an expert on multi-context setups, but I would think the base_url would be either

          private/   

          (slash at the end, not the beginning)


          or else

          h ttp://mysite.com/private/


          (take out the space after the h - had to put it in to keep the forum code happy).
            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
            • 38127
            • 5 Posts
            Quote from: BobRay at Jan 03, 2012, 02:09 AM
            I am. Thanks for the kinds words. I'm not an expert on multi-context setups, but I would think the base_url would be either

            private/   

            (slash at the end, not the beginning)


            or else

            h ttp://mysite.com/private/


            You're welcome. The book is on my to purchase list this week.

            Got it. I set the base_path to /home/mysite/public_html/private/, base_url is private/ and site_url to http://mysite.com/private/. I dumped the values out on the home page using system variables.

            Now to go back and find out if I need base_url as private or /. Supposed it just converts relative paths.

            Thanks.
              • 38127
              • 5 Posts
              Hmm, for some reason I can't edit my post. The base_url must be private/.

              Now to document this in my notes.

              Does Modx have some in depth documentation on the internals such as how does the manager do what it does. I know it uses connectors, etc. but is there any documentation that explains how to put them together. I've looked at the help and guide but it's pretty high level.

              Thanks again.
                • 3749
                • 24,544 Posts
                FYI, in MODX virtually all constants and variables relating to paths and URLs have a trailing slash (and not one at the beginning). Remembering that will save you a lot of time.

                In System Settings, you can use {base_path}, {assets_path}, {core_path}, {site_url}, {base_url}, and {assets_url} (all will end with a slash).

                {assets_path}images/myimage.jpg


                In PHP code, you can user this form for all the same ones: MODX_BASE_URL, MODX_CORE_PATH, etc.. Again, all end with a slash:

                include MODX_CORE_PATH . 'components/mycomponent/myfile.php';



                I don't know of any in-depth stuff on the Manager, though this may help: http://rtfm.modx.com/display/revolution20/Explanation+of+Directory+Structure. It may be a little out of date.

                Most of what I've learned about how the Manager works is based on creating a project out of the whole MODX core in a good code editor (PhpEd, NetBeans, PhpStorm) and wading through the code. It's not for the faint at heart. wink


                PhpStorm is by far the best, but it's not free. Once the project exists, you can search for classes and functions and you can right-click on something and jump to where it's declared, even if it's in a different file.

                I wouldn't consider, even for a second, working in MODX without a first-class code editor. PhpStorm will highlight any PHP, HTML, JavaScript, or CSS syntax errors, misspelled variable and function names, local variables that are unused, unreachable code, undeclared class member variables and functions, variables that might not be set when you use them (e.g., because they're set in an if() statement), and dozens of other errors that could eat up hours of your time.

                If you set up a debugger, you can run the index.php file in the root and trace through the code, optionally with breakpoints, though it's pretty tedious. When you need it, though, there's no substitute.

                [ed. note: BobRay last edited this post 12 years, 4 months ago.]
                  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
                  • 38127
                  • 5 Posts
                  Thank you for all the information. I've ordered the book so that should let me take advantage of what you learned <G>. That's how I've learned what I know - start using something and dig as deep as I can and then ask others who are more knowledgable and then go back and try and apply what I learned from them.

                  I'll look into the PHP editors you've listed.

                  Thanks again.