Textpattern CMS support forum

You are not logged in. Register | Login | Help

#221 2017-06-26 14:56:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,523
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

colak wrote #306091:

/*?businessloansfunded.com/…@ and /fundingteam+mydomain.tld.*?businessloansfunded.com/…@

Neither of those will match, so the emails will arrive. For the first one:

  • *? is not a valid regex character sequence.
  • .* is.

For the second:

Unless your emails are from the exact email address ‘/fundingteam+mydomain.tld@businessloansfunded.com’ they will not match. I assumed that ‘mydomain.tld’ was a variable each time, hence I replaced it in my example with .* (any character). So:

/fundingteam.*?@businessloansfunded.com/

should match any of these:

  • fundingteam+example.org@businessloansfunded.com
  • fundingteam+neme.com@businessloansfunded.com
  • fundingteamneme.org@businessloansfunded.com
  • blobbyfundingteamwhatever.com@businessloansfunded.combobulated

EDIT: the last one will match because we’re not anchoring the search pattern to the “start” and “end” of the string. If you wanted to do that, you would use the ^ (start) and $ (end) like this:

/^fundingteam.*?@businessloansfunded.com$/

Last edited by Bloke (2017-06-26 14:59:55)


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

#222 2017-06-26 15:03:00

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 1,382
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

? per your reasons: *? is not a valid regex character sequence.

/fundingteam.*?@businessloansfunded.com/

should it be

/fundingteam.*@businessloansfunded.com/

i.e. sans “?”


…. texted postive

Offline

#223 2017-06-26 15:10:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,523
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

bici wrote #306093:

‘*?’ is not a valid regex character sequence, should it be /fundingteam.*businessloansfunded.com/…@

Well, it could. But the question mark is a modifier for the previous “thing” (in this case the .* – any number of characters) that stops it being greedy and consuming more letters than necessary. Normally, regex patterns are greedy. While in this case — with so much extra text around it, the greediness is probably not an issue, it was just me being cautious in case the input string was mangled in some other way. You can probably omit the question mark. But the .* is important:

  • The dot means “any single character”
  • The star means “zero or more of the preceding character”

So, .* means, technically, “zero or more characters, any characters, doesn’t matter, as many as you can find until you hit the next part of the expression that matches”.


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

#224 2017-07-04 09:53:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

I am trying to create a custom subject line for the emails received from the form

What I currently have is:

txp 
<txp:zem_contact to_form="my_zem_contact_to_form" 
subject_form="State_Machines_Inquiry"  thanks="Thank you, your message has been sent.">
...

I created the subject_form and in it, I have:

<txp:php>
global $zem_contact_form;
echo $zem_contact_form['State Machines Inquiry'];
</txp:php>

but the emails are arriving with a (no subject) title. Can anyone point me to what I might be doing wrong?


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#225 2017-07-04 10:32:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,523
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

So your <txp:zem_contact> container has something like this in it?

<txp:zem_contact to_form="my_zem_contact_to_form" 
subject_form="my_zcr_subject" thanks="Thank you, your message has been sent.">
<txp:zem_contact_email />
...
<txp:zem_contact_select label="State Machines Inquiry" options="General inquiry, Specific inquiry, Just for fun" />
...
</txp:zem_contact>

As long as your Form is called my_zcr_subject and has the code you specified above, it’ll pick it up and use it by matching the label you used inyour select dropdown to the $zem_contact_form key. Your subject_form name needs to match exactly, including upper-and lower-case. It works in my tests here.


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

#226 2017-07-04 11:10:46

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

I see what you mean and that might be a usability issue.

In the select field I have

<txp:zem_contact_select name="Organisations" label="Select organisation you wish to contact" options="General inquiry, Specific inquiry, Just for fun" />

By changing the label, it will make it harder for the people to understand what that pull down does.

I’ll have to rethink what will be good for us, and for the visitors.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#227 2017-07-04 11:16:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,523
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

What’s the advantage to your receipients to have a user-selected subject line? Your ‘Organisation’ field already determines who receives the email. You can either hard-code the subject line in the form itself, or use another select with a list of subjects in it that users can choose.

If it’s important to your visitors (and recipients) to be able to pick what an email is about from a pre-defined list in the ZCR form, then add a second select to the form. It adds to the burden for the users though (one more form field) so consider any perceived benefits wisely!


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

#228 2017-07-04 11:23:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

Bloke wrote #306189:

What’s the advantage to your receipients to have a user-selected subject line? Your ‘Organisation’ field already determines who receives the email. You can either hard-code the subject line in the form itself, or use another select with a list of subjects in it that users can choose.

If it’s important to your visitors (and recipients) to be able to pick what an email is about from a pre-defined list in the ZCR form, then add a second select to the form. It adds to the burden for the users though (one more form field) so consider any perceived benefits wisely!

Hi Stef, thanks yet again!!!

The advantage will be that of properly searching for the emails in gmail. How can I hard-code the subject? In fact I was looking for that. Would it be:

<txp:zem_contact_select subject="State Machines inquiry" name="Organisations" label="Select organisation you wish to contact" options="General inquiry, Specific inquiry, Just for fun" />

> Edit: Yes it is!! wonderful…. Done!

Last edited by colak (2017-07-04 11:26:33)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#229 2017-07-04 11:36:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,523
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

colak wrote #306190:

subject=“State Machines inquiry”

I’m confused! If you add that attribute to your main <txp:zem_contact> tag, then yes, it’s hard-coded. You’ll always see that subject line in all received mails.

If you add a select list to your form, it’s just another field. It gets sent in the body of the message as a separate field, as normal, and appears in your email with the given label.

What makes a particular select field “special” is if you hook into one of them using the subject_form (or to_form) attribute instead. That then allows you to extract whatever is chosen by the user and pipe the value to a dedicated part of the email: the subject line, and the recipient respectively in these cases.

The select fields still get sent in the email body, regardless. Look at a received mail and you’ll see the organisation displayed in it.

So if your goal is to allow users to chose what their email is “about” then add a select list and hook it into the subject line via the subject_form attribute. If your goal is to just change thedefault “[Site name] > Enquiry” subject line to something else for all emails, hard-code it in the subject attribute of your main <txp:zem_contact /> tag.


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

#230 2017-07-04 13:07:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: zem_contact_reborn v4.5.0.0: contact mail form processing

No reason to be confused. I’m the one who was the space cadet here. Hard-coding it in the <txp:zem_contact_select subject="SMI" .../> did the trick.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

Board footer

Powered by FluxBB