We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    I want to test a new template & CSS for a site redesign.

    Is there any "easy" way to do this?

    I'm not familiar with Contexts. Theoretically I'd like to duplicate the main context, then experiment with it ... but how can I access it without having to mess around with subdomains, htaccess, etc.?

    Is there any way to "go" to a 2nd context via simple URL?

    E.g., say our "live" site is at "www.foo.com" ... I want to duplicate that context, call it "testing", then be able to navigate to the root of the 2nd context with "www.foo.com/testing".

    So the duplicate of "foo.com/container/page" would be at "foo.com/testing/container/page" in the 2nd context.

    Possible?
      • 19872
      • 1,078 Posts
        • 6531
        • 154 Posts
        Thanks, but ... I'm not getting it. Can I put "foo.com/testing" in the value for http_host?
        And then all containers with sub-resources will all link correctly via FURL aliases?
          • 6531
          • 154 Posts
          ... or can I just make up a subdomain ("testing.foo.com") without actually setting it up at our DNS?
            • 6531
            • 154 Posts
            Well, I did it ... but had to add a subdomain at our hosting.

            Thanks!

            Now, after testing, how would I go about making the new context the 'main' context?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              If all you are doing is changing the template, why a context at all? Use a branch in the Tree to have a sampling of duplicates of your resources, probably the home page, a gallery page, a page with a form, and the like, then when you're done either edit your existing templates or use Batcher to switch your resources to using the new template. Change the default_template setting as well.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 46886
                • 1,154 Posts
                Yeah this seems totally unnecessary and a lot of trouble for nothing. Just make a new template and upload the css to the right place, make sure the template is directed to the css and that the template has the [[*content]] snippet, copy whatever contents you want into a new resource, save, change the template of that resource to the new template and save again, then check it. You can leave it unpublished and no one can see it unless they are logged in.
                  • 40045
                  • 534 Posts
                  I do that on the fly without duplicating anything...just create a plugin and activate it for the system event "OnLoadWebDocument" with the following code:

                  $devmode = $modx->getOption('devmode', $modx->user->getSettings(), 0);
                  
                  if ( $devmode ) {
                  	if ( $modx->resource->template === 1 ) {
                  		// resource has default template, switch it to the dev template
                  		$modx->resource->set('template', 33);
                  	}
                  	return;
                  } else {
                  	return;
                  }
                  


                  you have to adapt the id of the default template, e.g. the "1" in the code above should be the template ID of resources you want to test the new template with and the "33" should be the ID of you new to-test template...

                  additionally you have to create a user setting (for your user) "devmode" (yes/no type) and set it to yes to activate the plugin...like this (when logged in) you will get the page rendered with the new template, while everybody else should get the site with the normal template...