Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2007-03-13 09:41:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,476
Website GitHub

Re: zem_contact_reborn 4.0.3.19 (old version)

lee wrote:

Is it possible to have a link with parameters, like ?topic=Spain, open a new page with a form on and to have the topic field pre filled by the link parameter value?

Not sure if it handles it natively in the latest rev (never tried) but if you don’t mind getting your hands dirty with a little PHP it’s possible. This is untested but the general idea is:

<txp:zem_contact to="blah@blah.com" label="E-mail us" thanks_form="contact_thanks" >
<txp:php>
  $theTopic = gps('topic');
  echo '<txp:zem_contact_text label="Topic" default="' .$theTopic. '" />';
</txp:php>
<txp:zem_contact_textarea label="Comments" />
<txp:zem_contact_text label="Name" />
<txp:zem_contact_text label="Company" />
<txp:zem_contact_email />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>

You can get as creative as you like: I’ve used the HTTP referer to determine which option in a select list to set as SELECTED (or default to some generic item if referer not set).

Hope that helps, unless anyone has any better ideas.

Last edited by Bloke (2007-03-13 09:45:52)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#74 2007-03-13 10:07:48

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: zem_contact_reborn 4.0.3.19 (old version)

Hi Stef, thanks for the code. I’m not a PHPer so I used it as is, but the topic field remained empty when I tried it. I put the code in a form and called the page it’s on with <href=“http://www.mysite.com?topic=“spain”>Inquiry</a>

Been in Cov long? I was born there.

Offline

#75 2007-03-13 10:24:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,476
Website GitHub

Re: zem_contact_reborn 4.0.3.19 (old version)

lee wrote:

I put the code in a form and called the page it’s on with <href=“http://www.mysite.com?topic=“spain”>Inquiry</a>

Curious. Works for me. Try without the quotes around Spain?

Been in Cov long? I was born there.

Yeah, around 12 years now.

Last edited by Bloke (2007-03-13 10:31:08)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#76 2007-03-13 11:56:34

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: zem_contact_reborn 4.0.3.19 (old version)

All working now – thank you very much for your help.

Offline

#77 2007-03-13 13:53:07

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: zem_contact_reborn 4.0.3.19 (old version)

Hi Stef, sorry to bug you again, but although the field is pre filled, the field not getting sent in the email.

Offline

#78 2007-03-13 16:53:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,476
Website GitHub

Re: zem_contact_reborn 4.0.3.19 (old version)

lee wrote:

although the field is pre filled, the field not getting sent in the email.

Dang, you’re right. I’m sure it used to work. Sorry to give you bogus info. Perhaps this version keeps track of which attributes are supplied to the zem_contact tag and only allows those to be sent? Maybe it doesn’t “see” the pre-filled text field because it’s masked by the PHP tags? * shrug *

If that’s the case I’d expect it to ignore it completely, instead of rendering it correctly on the page and not including it in the form output. Curiouser and curiouser, said Alice.

I’ve had a look through the plugin but it’s mighty clever stuff in there; beyond my current level of PHP-ness. If I spot anything I’ll check back in, but in the meantime… can anyone else help?

Last edited by Bloke (2007-03-13 17:03:34)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#79 2007-03-13 18:27:01

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

This one does work:

<txp:php>
  $topic = preg_match('/^[\w -]{1,50}$/', gps('topic')) ? gps('topic') : '';
  echo parse('<txp:zem_contact_text label="Topic" default="'.$topic.'" />');
</txp:php>

If the visitor shouldn’t be able to change or see the ‘topic’, then you could also do this:

<txp:zem_contact_secret label="Topic"><txp:php>
  echo (preg_match('/^[\w -]{1,50}$/', gps('topic')) ? gps('topic') : '');
</txp:php></txp:zem_contact_secret>

(some extra code added to ensure that the topic only contains alpnanumeric characters and underscore/dash/space and is no longer than 50 chars.)

Last edited by ruud (2007-03-13 20:35:16)

Offline

#80 2007-03-13 20:33:04

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: zem_contact_reborn 4.0.3.19 (old version)

Hi Rudd, thanks for helping out. I tried your code but get:

Parse error: syntax error, unexpected ‘;’ in /users/home/……/textpattern/publish/taghandlers.php(2681) : eval()’d code on line 3

Last edited by lee (2007-03-13 20:34:33)

Offline

#81 2007-03-13 20:35:33

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Oops, fixed it in the above code (the end of the ‘parse’ line was incorrect).

Last edited by ruud (2007-03-13 20:40:59)

Offline

#82 2007-03-13 20:42:09

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: zem_contact_reborn 4.0.3.19 (old version)

Many thanks for all the help guy’s, it’s much appreciated. The code is working perfectly now.

Offline

#83 2007-03-16 21:41:21

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Hi.

I have updated today to .19 and now when I use the contact form, I’m receiving e-mails twice.
I haven’t changed anything in the contact form.

I think I have found what’s going on and it seems to be a bug: when there is a copysender="yes", both e-mails (the original, and the copy to the sender) are being sent to the recipient.
I have tried removing the copysender attribute and this second test worked as expected: I have received the mail just once.

Please, can anyone confirm? Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#84 2007-03-16 22:28:15

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

BTW: if you have both zem_contact_lang and zem_contact_lang_mlp (that, as I understand, right now is useless because zem_contact_reborn isn’t configured to play nice with MLP) activated, in the front-end I get this error, and all the site broken:


Fatal error: Cannot redeclare zem_contact_gtxt() (previously declared in /home/mgo/html/textpattern/lib/txplib_misc.php(512) : eval()'d code:75) in /home/mgo/html/textpattern/lib/txplib_misc.php(512) : eval()'d code on line 2

In the meanwhile, to avoid this problem, I have de-activated MLP zem_contact_reborn_MLP.

Last edited by maniqui (2007-03-16 22:29:29)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB