<label for="subject">Subject<span class="required">*</span></label> <input type="text" name="Subject" id="subject" class="text" value="[*pagetitle*]" eform="Subject::1" />
I rather not use any CSS hacks so how do I do the first or second solution? i tried
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.
http://site.com/form?subject=[*pagetitle*]
http://site.com/form?subject=70%20Washington%20Sq.%20South
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.
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.
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.
[!SaveAlias!]
<?php /* SaveAlias snippet */ $_SESSION['myAlias'] = $modx->documentObject['alias']; ?>
<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
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']; ?>