Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-08-19 13:02:24
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Inquiry form that picks up an item’s catalogue reference no. ?
I’m working on a property site presenting each property as an individual article.
Each of them also has a unique reference no. assigned through a custom field.
Now I would like to add a simple text link “Send inquiry” that takes the user from the article to a contact form and also picks up the reference number and places it in the subject field of the generated mail output.
Any pointers would be very much appreciated!
Cheers Martin
Offline
Re: Inquiry form that picks up an item’s catalogue reference no. ?
You could make your send enquiry button link to the url of your contact form with ?refnum=12345 and then use chs_ifurlvar on your contact form to create the subject line or special field or whatever. BTW:you may need to nest tags to get it to work – how to do that is listed in the FAQ.
TXP Builders – finely-crafted code, design and txp
Offline
#3 2006-08-19 18:37:41
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Re: Inquiry form that picks up an item’s catalogue reference no. ?
Thanks Jakob,
that looks very promising.
I had no problems passing on the url variable from the article page, however I seem to be unable to get it written anywhere into my contact form. This is the contact form that works except for automatically filling in the refnum.
<code><txp:zem_contact mailto=“name@domain.com”>
<txp:zem_contact_email /><br />
<txp:zem_contact_text label=“Reference Number” max=5 /><br />
<txp:zem_contact_textarea label=“Enquiry” /><br />
<txp:zem_contact_submit label=“Send” />
</txp:zem_contact></code>
<br />
I’m familiar with the nesting of tags and have already installed chs_ifurlvar but I don’t know where to go from here.
First I though I could do something like this:
<code><txp:zem_contact_text label=“Reference Number” max=5 default=(output from chs_ifurlvar) /><br /></code>
<br />
but it’s not possible to use the output of a txp tag as an attribute’s value.
Any ideas?
Last edited by masa (2006-08-19 18:53:52)
Offline
Re: Inquiry form that picks up an item’s catalogue reference no. ?
masa wrote:
<txp:zem_contact mailto="name@domain.com">
<txp:zem_contact_email /><br />
<txp:zem_contact_text label="Reference Number" max=5 /><br />
<txp:zem_contact_textarea label="Enquiry" /><br />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
You can add any value into the set zem_contact returns with the message by adding an appopriate array member to the global $zem_contact_form variable. You’ll need a dash of PHP in order to do so, plus the contact form has to be put inside the article’s page (because your custom field’s value will be available just there):
<txp:php>
global $zem_contact_form;
$zem_contact_form['refno'] = custom_field (array('name' => 'your_custom_field_name'));
</txp:php>
// continue with standard zem_contact tags...
<txp:zem_contact mailto="name@domain.com">
<txp:zem_contact_email /><br />
<txp:zem_contact_text label="Reference Number" max=5 /><br />
<txp:zem_contact_textarea label="Enquiry" /><br />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
If you wanted to keep the behaviour of having a separate contact page receiving the refno as an URL var, you’d have to adapt this snippet:
... custom_field (array('name' => 'your_custom_field_name'));
Last edited by wet (2006-08-20 07:00:08)
Offline
Re: Inquiry form that picks up an item’s catalogue reference no. ?
Yes, like wet said, you’ll need the php to get tags within tags working for the bit you marked (output from chs_ifurlvar). See also the article I mentioned above Can I use tags within tags? from the FAQ.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2006-08-21 10:13:59
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Re: Inquiry form that picks up an item’s catalogue reference no. ?
Thanks Robert and Jakob,
I know very little PHP, but it does look easy enough.
I’ll try that and might get back to you should any questions arise.
Cheers Martin
Offline
Re: Inquiry form that picks up an item’s catalogue reference no. ?
To send an URL var use this sequence:
<txp:php>
global $zem_contact_form;
$zem_contact_form['refno'] = gps('refno');
</txp:php>
//w&
Offline
#8 2006-08-26 16:10:14
- masa
- Member
- From: North Wales, UK
- Registered: 2005-11-25
- Posts: 1,095
Re: Inquiry form that picks up an item’s catalogue reference no. ?
Thanks again, Robert.
I’m away at the moment but will try this as soon as I get back.
Cheers Martin
Offline