We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3689
    • 264 Posts
    I have a contact form at site.com/form but on site.com/properties/home1 i want to add a link to a popup which will display the form from site.com/form.. since my <a> link is on the home1 page, is there a way I can get "home1" to display in the subject field? right now i have:
    <label for="subject">Subject<span class="required">*</span></label>
    <input type="text" name="Subject" id="subject" class="text" value="[*pagetitle*]" eform="Subject::1" />
    but it displays "Form" since thats the pagetitle of the current page.. how can I fix this?
      • 5340
      • 1,624 Posts
      On way would be to POST the subject.
      On the referring page you need a link or a button that you can use as a submit button.

      Another way is to read the referring URL and based on the value populate the field. I think you’ll need to use an eForm event to set the correct subject.

      ...and I guess the simplest way is to have the contact form on that page. Why go to another page? Just hide the contact form from css and make it pop-up/show when you click on a link. This is easyly doable with any javascript framework.



        • 3689
        • 264 Posts
        Quote from: cipa at Feb 08, 2010, 07:24 AM

        On way would be to POST the subject.
        On the referring page you need a link or a button that you can use as a submit button.

        Another way is to read the referring URL and based on the value populate the field. I think you’ll need to use an eForm event to set the correct subject.

        ...and I guess the simplest way is to have the contact form on that page. Why go to another page? Just hide the contact form from css and make it pop-up/show when you click on a link. This is easyly doable with any javascript framework.




        I rather not use any CSS hacks so how do I do the first or second solution? i tried
        http://site.com/form?subject=[*pagetitle*]

        which became
        http://site.com/form?subject=70%20Washington%20Sq.%20South
        but it didnt populate the subject field
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          You’d have to retrieve the variable from the $_GET array on the receiving page for that value to populate. But I that is a bad way to do it... there’s the vulnerability of cross site scripting with that approach, which is a sure fire way to get your site hacked.

          What I’d recommend is using a Snippet to look up the title of the parent page. It boils down to a database query something like
          SELECT pagetitle FROM site_content WHERE id=’xxxx’

          Where ’xxx’ would be the parent_id of the current page.
            • 3689
            • 264 Posts
            Quote from: Everett at Feb 08, 2010, 04:08 PM

            You’d have to retrieve the variable from the $_GET array on the receiving page for that value to populate. But I that is a bad way to do it... there’s the vulnerability of cross site scripting with that approach, which is a sure fire way to get your site hacked.

            What I’d recommend is using a Snippet to look up the title of the parent page. It boils down to a database query something like
            SELECT pagetitle FROM site_content WHERE id=’xxxx’

            Where ’xxx’ would be the parent_id of the current page.

            is there anywhere i can look to learn the php i need to do this?
              • 5340
              • 1,624 Posts
              The parent page is not always the referrer page. If that’s the case then I’ll stick with the css/javascript solution.
              The other solution I was talking about is too complex if you’re not familiar with php and how modx works.
                • 3749
                • 24,544 Posts
                Quote from: cipa at Feb 08, 2010, 06:12 PM

                The parent page is not always the referrer page. If that’s the case then I’ll stick with the css/javascript solution.
                The other solution I was talking about is too complex if you’re not familiar with php and how modx works.

                You could extract the alias from http_referrer and query the database to get the pagetitle of the page with that alias. If you did it in a plugin, I think you could populate any fields in the form, but you’d have to be fairly skilled at PHP.
                  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
                  • 3689
                  • 264 Posts
                  Quote from: BobRay at Feb 08, 2010, 11:23 PM

                  Quote from: cipa at Feb 08, 2010, 06:12 PM

                  The parent page is not always the referrer page. If that’s the case then I’ll stick with the css/javascript solution.
                  The other solution I was talking about is too complex if you’re not familiar with php and how modx works.

                  You could extract the alias from http_referrer and query the database to get the pagetitle of the page with that alias. If you did it in a plugin, I think you could populate any fields in the form, but you’d have to be fairly skilled at PHP.


                  im going to have a link to site.com/form from site.com/properties/home1, site.com/properties/home2, site.com/properties/home3 etc.. I’m trying to create a "Request Appointment" form that will populate the subject field with the Home Address.. maybe the way I’m going about this is wrong, but I do need a link that will link on the property page that will then pop up the request form.. would this solution work? Or is there a better way I can do this?
                    • 3749
                    • 24,544 Posts
                    There may be an easier way to do it, but I’d put a snippet in the template of the individual property page, called SaveAlias, that saves the alias of that page in a $_SESSION variable. Then, I’d put a snippet, called GetAlias, on the Request Appointment page that reads the $_SESSION variable and populates the form.

                    Something like this (untested):

                    For the individual property page:

                    [!SaveAlias!]


                    <?php
                    /* SaveAlias snippet */
                    $_SESSION['myAlias'] = $modx->documentObject['alias'];
                    
                    ?>


                    For the request appointment page:

                    <input value="[!GetAlias!]" . . . />



                    <?php
                    /* GetAlias snippet */
                    return $_SESSION['myAlias'];
                    ?>
                    



                      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
                      • 3689
                      • 264 Posts
                      Quote from: BobRay at Feb 15, 2010, 11:50 PM

                      There may be an easier way to do it, but I’d put a snippet in the template of the individual property page, called SaveAlias, that saves the alias of that page in a $_SESSION variable. Then, I’d put a snippet, called GetAlias, on the Request Appointment page that reads the $_SESSION variable and populates the form.

                      Something like this (untested):

                      For the individual property page:

                      [!SaveAlias!]


                      <?php
                      /* SaveAlias snippet */
                      $_SESSION['myAlias'] = $modx->documentObject['alias'];
                      
                      ?>


                      For the request appointment page:

                      <input value="[!GetAlias!]" . . . />



                      <?php
                      /* GetAlias snippet */
                      return $_SESSION['myAlias'];
                      ?>
                      




                      It doesnt seem to be working.. it prints [!GetAlias!] into the form field instead of the actual alias