We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21606
    • 46 Posts
    MODX Revolution 2.2.8-pl (traditional)
    FormIt 2.2.0

    Working on a 'Tell a Friend' form and want to grab the current page the viewer is sitting on, save it in a placeholder and have it available to include in the email being sent to the friend. The current process I'm using links (on a button press) to a resource with the necessary FormIt configuration and template calls to fill out the form, then I want to include the page link in the out-going email. The site uses friendly urls so I'm thinking that writing a prehook to set a placeholder value to the page alias may be the way to go.
    Does this make sense or is there a better option?

      • 36996
      • 211 Posts
      You can include a hidden input in your form, and in the value get the page id:
      <input type="hidden" name="pageId" value="[[*id]]">

      Then you can use it in the email with the placeholder
      [[+pageId]]
        • 30912
        • 463 Posts
        We do similar but use pagetitle so like nir-z said

        	
        <input type="hidden" name="title" value="[[*pagetitle]]">
          • 34926
          • 87 Posts
          The hidden field is probably the easiest method. You could use [[*alias]] as the value in this scenario.

          Alternatively if you needed to do something more involving you could use FormIt's hooks http://rtfm.modx.com/extras/revo/formit/FormIt.Hooks.
            • 21606
            • 46 Posts
            Quote from: Tyreal2012 at Sep 06, 2013, 03:48 PM
            We do similar but use pagetitle so like nir-z said

            	
            <input type="hidden" name="title" value="[[*pagetitle]]">

            Thank you Tyreal,
            I appreciate your answer very much, and similar to nir-z and you I thought about and tried this but realized that it will only work if I'm sending the page that the viewer is on and they stay on it. Am opening an iframe and need to insert the link into an outgoing message. But you and nir-z did answer another question I'd been thinking about...


            nitrojane
              • 36996
              • 211 Posts
              I had a situation of a contact form in an iframe.
              What you can do is pass the page id to the iframe url like this:
              <iframe src="[[~45]]&pageId=[[*id]]"></iframe>

              And then the id will be available to use in a snippet.
                • 30912
                • 463 Posts
                Quote from: nitrojane at Sep 09, 2013, 01:14 PM
                Quote from: Tyreal2012 at Sep 06, 2013, 03:48 PM
                We do similar but use pagetitle so like nir-z said

                	
                <input name="title" value="[[*pagetitle]]" type="hidden">

                Thank you Tyreal,
                I appreciate your answer very much, and similar to nir-z and you I thought about and tried this but realized that it will only work if I'm sending the page that the viewer is on and they stay on it. Am opening an iframe and need to insert the link into an outgoing message. But you and nir-z did answer another question I'd been thinking about...


                nitrojane

                Ah, then nir-z's response is correct, your inital post mentioned the current page but no mention of the iframe (although i shouldve assumed as you said grab)

                hope you get it sorted.