Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-02-05 23:38:13

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

zem_contact_reborn v4.5.0.0: contact mail form processing

IMPORTANT: This plugin is now deprecated and has been rebranded as com_connect.

Original thread retained for historical value below.
———————————————

Following on from the rock-solid v4.0.3.20 this is the next iteration of the plugin. If you don’t care why you need it you can grab a compiled copy from GitHub.

Installation

  • Backup your existing plugin / site if using a prior version of the plugin.
  • Disable zem_contact_lang if it’s installed.
  • Install and activate the new zem_contact_reborn plugin.

French and English textpacks are distributed with the plugin by default. If anybody has any translations, please send the textpacks to me for inclusion in the final release. I’ll also host them separately on my site or maybe with the GitHub release if I can add to it (not sure if that’s possible).

What’s new

Documentation is pretty fully featured so I’d advise you start there if in any doubt. But for the most part, it’s a drop-in replacement for v4.0.3.20 that has been significantly refactored behind the scenes to allow other plugins to have more control over the mail process. From the tag side, you have a whole raft of HTML 5 input attributes available. These include:

  • accesskey
  • autocomplete
  • autofocus
  • class
  • dir
  • disabled
  • form (auto-filled in on your behalf by default)
  • hidden
  • id
  • lang
  • list
  • max
  • min
  • pattern
  • placeholder
  • readonly
  • spellcheck
  • step
  • style
  • tabindex
  • title
  • translate
  • type (for <txp:zem_contact_text> only)
  • wrap (for <txp:zem_contact_textarea> only)

These attributes are not universal for every type of input widget, they are only applied where it makes sense and if your Textpattern installation has been set to output HTML 5. If you’re in any doubt what’s accepted where, consult the W3C spec as this follows it as closely as I can, considering it’s a moving target.

In addition, the <txp:zem_contact> tag accepts these additional attributes:

  • body_form so you can define body content in a Form.
  • expire so you can set how long, in seconds, the form expires (default: 600)
  • required which allows you to globally toggle on or off the required attribute for all contained ZCR tags. By default they’re all set to be ‘required’ but there are times you may want to have a form where most of the fields are optional. In the old plugin you had to explicitly turn off the required attribute for every tag, but now you can just turn it off once in the main ZCR container tag and then switch it on only for the tags you need. Or vice versa.

There’s also a new <txp:zem_contact_option> tag so you can define custom select lists inside your <txp:zem_contact_select>, and a conditional tag <txp:zem_contact_if> which accepts name/label/value attributes to compare the given attribute name or label against the given value. Haven’t fully tested that yet, reports or improvements welcome.

For programmers wanting to try out the new zemcontact.deliver callback, the code is fairly well documented. Lots of fun can be had in plugins by either:

  • altering the $payload passed to your plugin, such as adding Multi-part MIME headers for HTML emails (the zemcontact.render callback works in tandem with this for making alterations to the front-end form).
  • returning zemcontact.send (or no return value) to allow Zem Contact Reborn to continue mailing the content.
  • returning zemcontact.skip to skip zem_contact’s mailing (i.e. your code handles mailing) and return ‘success’ message.
  • returning zemcontact.fail to skip zem_contact’s mailing and return ‘fail’ message.
  • exit from inside your plugin after doing your code, but note this will not do any ZCR redirect that may be in place.

You can also target the first or second (copysender) send process by hooking into the callback’s step using send or copysender respectively. Or omit it to have your plugin called twice.

The idea behind this release is that it’s more of a platform for communication than just for plain mailing. The callbacks allow all manner of additional plugin to spring up. Examples:

  • HTML email sending.
  • Anti-spam modules.
  • Captcha (yuk!) modules.
  • Third party mailer integration (e.g. MailChimp).
  • Send attachments / file upload facility.

Out of the box, it will still send plain old email. But the possibilities for using it as a springboard for other purposes are greatly enhanced, so I’m looking forward to what you can dream up. I’ve already written some companion modules for it which will probably get released at some point (MailChimp integration and file attachments). Watch this space.

In the meantime, have fun and please report anything good, bad or indifferent here. Happy contacting.

Last edited by Bloke (2017-07-18 23:38:47)


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

Offline

#2 2016-02-06 12:06:32

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 809
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

@Bloke … this is great, super, fantastic … and with MailChimp support … :))))

Offline

#3 2016-02-06 13:16:15

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,743
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Brilliant. Thank you!

Will existing plugins that hooked into zcr need changing for the callbacks, or is that backwards-compatible/same-as-before?


TXP Builders – finely-crafted code, design and txp

Offline

#4 2016-02-06 13:39:23

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,227
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Am I doing something wrong ? I get a bunch of tag errors in debugging mode – TXP 4.6dev:

Tag error: <txp:zem_contact label="foo" to="recipient@example.com"> ->  Textpattern Notice: unregistered_tag while parsing form pw_contact on page default

the form pw_contact is just a typical form of the misc type called by <txp:output_form form="pw_contact" />

That said everything seems to work fine so far, the form is displayed etc. Not sure if the mail actually is send, can’t test that on my local dev install.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#5 2016-02-06 13:46:13

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

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

jakob wrote #297769:

Will existing plugins that hooked into zcr need changing for the callbacks.

Not as far as I’m aware. The new callbacks are additions only.

I think pap_contact_cleaner still works as-is for example. What other plugins are there I need to test?

phiw13 wrote #297771:

Textpattern Notice: unregistered_tag

D’oh. Helps if I register the tags. I have my dev site in Testing mode because that warning was winding me up in other plugins and I forgot to switch to debugging before release. I’ll add an issue and get it resolved, thanks.


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

Offline

#6 2016-02-06 15:41:59

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Well done! Thanks Stef.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#7 2016-02-07 07:18:42

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,540
Website GitHub Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Hi Stef

Great it was time to improve our old zem_contact_reborn!

Have you added a required ad on input field like that also when it required, becauseit s used by foundation form validation:

<input name="myinput" required />

Offline

#8 2016-02-07 07:38:22

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,227
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Bloke wrote #297772:

D’oh. Helps if I register the tags.

Oh good, an oversight… Fixed I see (I hacked my local installed copy continue playing around without the noise now). Thanks.

@Dragondz Yes it is there, configurable.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#9 2016-02-07 08:52:16

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,540
Website GitHub Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

@phiw13

Thanks for the clarification.

Offline

#10 2016-02-07 21:14:48

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 304
Website GitHub Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Thanks Stef: great stuff. I appreciate the extensive help text :)

Continuing from this thread:

I upgraded my form to the new plugin and did some more testing.

  1. New user emails get received, whether sent to external or domain-native email addresses.
  2. I still get the Sorry, unable to send email. failure message whether I have the ‘SMTP envelope sender address’ field filled with a domain-native email address or left empty.
  3. I tried disabling fields to see where the problem lay, and discovered that the form works every time, as long as I exclude the <txp:zem_contact_email /> field.

I’m stuck :(

What should I try next? Thanks all…

Offline

#11 2016-02-11 14:01:26

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,640
GitHub Twitter

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Hi Stef ;)

W3C validator error found: Bad value for autofocus="1"

<input class="zemText zemRequired" id="q614cffa523202658a898e34a5d94d05e" name="q614cffa523202658a898e34a5d94d05e" type="text" maxlength="100" autocomplete="on" form="zcr55c6e8afe672973fae7b31f0ae32a2a0" required="required" autofocus="1" dir="ltr" lang="en-gb" title=" Your First &amp; Last Names, required " />

It seems that autofocus allows autofocus="autofocus" or single word autofocus (same use as the required attribute).

Last edited by Pat64 (2016-02-11 14:05:56)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#12 2016-02-15 10:39:09

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

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Pat64 wrote #297828:

W3C validator error found: Bad value for autofocus="1"

Good catch, thanks. The new boolean attributes probably shouldn’t have any value at all if you are using HTML 5. Not sure how best to implement that, but I’ll see what I can do.


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

Offline

Board footer

Powered by FluxBB