We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18463
    • 121 Posts
    Martijn van Turnhout Reply #1, 16 years, 4 months ago
    Hi all,

    I want to learn how you can pass values from the previous page to the current page. Let me give you a random example:


    I REALLY would like to know how you can accomplish this with MODx. I believe it has something to do with GetField?

    Any help would be appreciated. Thanks!
      • 3749
      • 24,544 Posts
      I think the easiest thing would be a snippet on the page that writes the page info to placeholders. You’d put placeholder tags on the landing page.

      Another way (which might be a little more reliable) is to make the first page a form that "posts" to the landing page, and then have a snippet on the landing page that gets the info from the $_POST array and writes the placeholders.
        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
        • 26931
        • 2,314 Posts
        hmm, don’t know what you want to pass on ... but maybe this snippet helps: http://bit.ly/7BL0MG
          • 20413
          • 2,877 Posts
          Awesome snippet! cool
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 18463
            • 121 Posts
            Martijn van Turnhout Reply #5, 16 years, 4 months ago
            Wow, that snippet looks exactly like what I need!

            Can anyone comfirm if it’s reliable? I would love to use it in different projects, but if it turns out to be buggy, I’ll be looking for something else then. Thanks!
              • 5340
              • 1,624 Posts
              Not sure if this was solved but here’s another way to do it

              Snippet 1 - SetCustomSessionVars

              <?php
              //SetCustomSessionVars
              // [!SetCustomSessionVars? &longtitle=`[*longtitle*]` &summary=`[*summary*]`!]
              
              //Add all the variables you want to track here
              
              $longtitle = (isset($longtitle)) ? $longtitle : '';
              $summary = (isset($summary)) ? $summary : '';
              //add more here. don't forget to add them in the snippet call too
              
              $_SESSION['longtitle'] = $longtitle;
              $_SESSION['summary'] = $summary;
              //add more here. don't forget to add them in the snippet call too
              
              ?>


              Snippet 2 - GetCustomSessionVar

              <?php
              //GetCustomSessionVar
              // [!GetCustomSessionVar? &var=`longtitle`!]
              
              $output = (isset($_SESSION[$var])) ? $_SESSION[$var]: '';
              
              //uncomment the line bellow if you want to delete the session after it is used
              //unset($_SESSION[$var]);
              
              return $output;
              
              ?>



              Call the first snippet call at the beginning of the template you want to record information from.
              Call the second snippet in the template you want to show the recorded information.
                • 18463
                • 121 Posts
                Martijn van Turnhout Reply #7, 16 years, 4 months ago
                Thanks a lot Cipa, this is starting to make sense for me now!

                Okay, my final question:

                For SEO and usability purposes, I want to give the second page (i.e. a contact page) an unique identifier. Something like www.domainname.com/contact?page=132 for people who want to know more about the product located on pageID 132 or www.domainname.com/contact?page=26 for those who want to know more about the product located on pageID26.

                So here’s my thing. I want to store the session data on the product page with (let’s say) pageID 132 and I only want to place those session variables on an uniquely identified contact page.

                This might sound a bit incomprehensible, but I have an example right here:

                http://caravanking.nl/actueel-aanbod/caravan-verkoop-Caravan-Dethleffs-Family-420-DB-te-koop.html

                The links "Tip een vriend" (tell-a-friend) and "Vraag over caravan" (question about the caravan) lead to pages where an unique identifer is used in the URL (?page=524) and certain session variables (like the name of the caravan and such) have been stored on that page.

                Now, I’m almost there... how do I do that?

                I know I might be asking a lot of question, but if I know this, I can do almost anything with MODx laugh!

                Thanks a lot in advance guys. Again.