We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    I have a Private section on my site for registered users only, currently when un-logged in visitor try to access the page they get the login form but after successful login they redirect to the site start.

    how can I send them to the page they tried to access instead?
      • 4310
      • 2,310 Posts
      Doesn’t
      [!WebLoginPE? &liHomeId=`51`!]
      work?
        • 27330
        • 884 Posts
        No because I have for example both "News" link and "Articles" in my toolbar which both are private.
        I need something like &liHomeId=`Destination ID`
          • 4172
          • 5,888 Posts
          you can do it for example like that, I think:
          &liHomeId=`[+phx:get=`goto`+]`
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 28609
            • 29 Posts
            Quote from: Bruno17 at Dec 15, 2008, 07:01 AM

            you can do it for example like that, I think:
            &liHomeId=`[+phx:get=`goto`+]`


            What value do I need to replace goto with? I am looking for the same thing the other poster is looking for.

            For example if you go to the main page of the site... http://arcpa.org/ and click the FedEx logo on the right, it takes you to the login page. After logging on, I want it
            to proceed to the FedEx page that was initially requested. Of course I want this to happen no matter what the original destination was, not just the FedEx page.

            Is there a modx variable that works like http_referer?
              • 3749
              • 24,544 Posts
              Phx is probably an easier way to go but it would be fairly simple with snippets, I think.

              One one-line snippet [!PutID!] on the page to save the current page ID as a $_SESSION variable.

              And another one-liner [!GetID!] to read and return that variable:

              &liHomeId=`[!GetID!]`

                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
                • 28609
                • 29 Posts
                Quote from: BobRay at Dec 19, 2008, 12:04 PM

                Phx is probably an easier way to go but it would be fairly simple with snippets, I think.

                One one-line snippet [!PutID!] on the page to save the current page ID as a $_SESSION variable.

                And another one-liner [!GetID!] to read and return that variable:

                &liHomeId=`[!GetID!]`



                Can I use this as a snippet and then call it in the &liHomeId parameter?


                function getCurrentPageUrl()
                {
                $pageURL = ’http’;

                if ($_SERVER["HTTPS"] == "on")
                {
                $pageURL .= "s";
                }

                $pageURL .= "://";

                if ($_SERVER["SERVER_PORT"] != "80")
                {
                $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
                }
                else
                {
                $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
                }
                $_SESSION[’CURRENT_PAGE_URL’] = $pageURL;

                }

                if ($_SESSION[’CURRENT_PAGE_URL’])
                {
                header(’location: ’.$_SESSION[’CURRENT_PAGE_URL’]);
                }
                else
                {
                //redirect to default url
                }
                  • 3749
                  • 24,544 Posts
                  That looks like it would work, but I’d be inclined to do this instead:


                  $_SESSION['CURRENT_PAGE_ID'] = $modx->resourceIdentifier;  // just save the ID of the current page.
                  
                  
                  if (isset($_SESSION['CURRENT_PAGE_ID'])) {
                  
                      $modx->sendRedirect($modx->makeUrl( (integer) $_SESSION['CURRENT_PAGE_ID'], '', '', 'full'));
                  
                  }


                  makeUrl() will handle https pages and friendly urls automatically. It might not handle alternative ports but you could easily tweak the makeUrl code if necessary:

                  http://wiki.modxcms.com/index.php/API:makeUrl
                    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
                    • 27330
                    • 884 Posts
                    Thanks for the replies.

                    I didn’t really understood how to use the above snippet, not sure for which page is it.
                    Do I still need a [!PutID!] and on which page do I place it?


                    anyhow, I did noticed that WebLogin snippet will direct me to the page I was on my way to.
                      • 3749
                      • 24,544 Posts
                      If I still understand what’s going on, [!PutId!] would go in the template so the id is saved for every page visted, and &liHomeId=`[!GetID!]` goes in the WebLogin call.
                        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