We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I think you might be able to use a snippet on the page to pull in one version or the other:

    $modx->sendForward($id);


    That should pull in the content of the other page without changing the URL. You’ll have to add some code above that the sets the $id (maybe one ID for odd hours of the day (or minutes) and another for even?).
      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
      • 17016
      • 138 Posts
      Hi BobRay,
      thanks a lot. I tried your code as well as this code:

      <?php
      $output = $modx->sendForward($modx->makeUrl(1));
      return $output;
      


      But the result is:
      Error 503: Site temporarily unavailable

      For randomization I added:
      srand ( (double) microtime() * 1000000 );
      $testversion = rand(1,2);


      I also added some cookies for making sure each visitor gets the same page even when returning to the page for a second time...
        • 3749
        • 24,544 Posts
        Sorry, I was thinking of sendRedirect(). sendForward () just takes the ID. Fixed in message above.
          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
          • 17016
          • 138 Posts
          Thanks for this solution. I just tried it but now the URL is changing. Do you have any idea how to output the whole content with the URL of the other page?
            • 33968
            • 863 Posts
            I might be mistaken Bob but I think those functions are for redirects, rather than grabbing content and including it on the current page.

            @letti: there’s likely a way to do it using the api, but it’s way above my head here I’m afraid.

            However, have you considered ajax?

            If you made your ’current page’ completely blank but for an ajax snippet, then you could pull in the content of the other page randomly using ajax. Something to get you started: http://modxcms.com/forums/index.php?topic=61483.0

            Also - kudos for building this yourself, but why not use Website Optimizer? smiley
              • 17016
              • 138 Posts
              If you want to use the Website Optimizer you have to use Google Analytics and accept their data privacy policies which can lead to bigger problems in some countries smiley
                • 3749
                • 24,544 Posts
                In theory, sendForward() will send the user to the specified page -- without changing the current URL (IOW, the user sees the URL of the page with the snippet tag calling sendForward(). If it’s not doing that, it may be a bug.
                  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
                  • 17016
                  • 138 Posts
                  OK. Thanks for this information. Can anybody else reproduce this "bug" or is this maybe a problem of our installation?

                  Letti
                    • 3749
                    • 24,544 Posts
                    Quote from: Letti at May 10, 2011, 12:56 AM

                    OK. Thanks for this information. Can anybody else reproduce this "bug" or is this maybe a problem of our installation?

                    Letti

                    Letti, this snippet is working fine for me in 2.0.7 with FURLs on or off. I see page 17, but the URL in the browser address bar is the one from the page with the snippet. I haven’t had a chance to test it in 2.1. What version are you using?


                    [[!SendForward]]



                    <?php
                    /* SendForward snippet */
                    $modx->sendForward(17);
                      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
                      • 17016
                      • 138 Posts
                      You are completely right. Thanks a lot. My mistake was this code:

                      $output = $modx->sendForward($modx->makeUrl(1));
                      return $output;