Textpattern Forum

You are not logged in. Register | Login | Help

#1121 2011-12-18 21:57:25

Gocom
Developer
Registered: 2006-07-14
Posts: 4,476
Website

Re: zem_contact_reborn 4.0.3.20

Or based on Ruud’s snippet, same with the help of a article_custom;

<txp:article_custom sort="custom_1 asc" limit="1" City='<txp:php> echo $GLOBALS["zem_contact_form"]["my-select-list-label"]; </txp:php>'>
	<txp:custom_field name="Email_address" default="info@example.com" />
</txp:article_custom>

Note that both, mine and Ruud’s will only return a single email address, not a list. If your idea is to return multiple addresses from multiple articles selected based on the city, and only show info@example.com as a fallback when no articles are found, you will need something bit different. Something like following:

<!--
	has_email named variable will be set "1" in the article's container,
	if addresses are found. For now we set it as "0".
-->

<txp:variable name="has_email" value="0" />

<!--
	List articles that have "Email_address" populated
	and "City" matched form's selection
-->

<txp:article_custom sort="custom_1 asc" Email_address="_%" limit="999" City='<txp:php> echo $GLOBALS["zem_contact_form"]["my-select-list-label"]; </txp:php>'>
	<txp:if_different>
		<txp:custom_field name="Email_address" default="info@example.com" />
	</txp:if_different>
	<txp:variable name="has_email" value="1" />
</txp:article_custom>

<!--
	Show fallback if no addresses were found.
-->

<txp:if_variable name="has_email" value="0">
	info@example.com
</txp:if_variable>

Please keep in mind that Textpattern doesn’t escape LIKE operators’ wildcard syntax in the custom fields’ SQL statements. If a value passed to article_custom’s custom_field attribute (custom_field="value") contains any wildcard characters (_, %), those will be treated as one and not as plain text. If any of the fields used to filter the list contains (or are populated with) any of those wildcard characters, you may get unexpected results say the least.

Last edited by Gocom (2011-12-18 22:18:02)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#1122 2011-12-19 11:12:43

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 542
Website

Re: zem_contact_reborn 4.0.3.20

Thanks Ruud and Gocom, I used Jukka second code to return multiple addresses (one from each article).
It works great, thank you very much! :)
And ohh…I wasn’t even close with the plugin help example :/

The idea was that I got a ‘showrooms’ section and a ‘contact’ page,
and in each showroom article the client enter it’s email address.
Now when a visitor choose a showroom from the select-list in the contact page form,
it will send the email to the address that the client set in that showroom’s article.
So now it’s all dynamic, I present the list of showrooms in the contact form using article-custom and now thanks to your code I set the to_form feature to be also dynamic with article-custom, so in the end the client can update showrooms and it all be done automatically.
(Besides of the default email address which is static)

Cool :)

Offline

#1123 2012-01-16 20:08:33

ajw-art
Member
Registered: 2010-02-10
Posts: 33

Re: zem_contact_reborn 4.0.3.20

I’m using ZCR to generate the contact me form on my webpage. It’s working as expected with one exception: the select field. To be specific, it’s the only field that doesn’t come through in the email that the form sends to me. Any ideas as to why this might be the case?

I did make some changes to the plugin code itself to enable support for the HTML5 placeholder attribute, but I can’t see where anything I’ve done would have disabled the select field. Here’s a link to the edited code on pastebin so you can see the changes I made. Any help would be much appreciated. Thanks!

Offline

#1124 2012-01-16 21:31:09

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 4,513
Website

Re: zem_contact_reborn 4.0.3.20

@ajw-art, it’s probably related to the “name” attribute value, which contains a space. Try replacing it with something without a space. This would’ve caused the same problem if you were using an unmodified ZCR ;)

Offline

#1125 2012-01-16 21:40:24

ajw-art
Member
Registered: 2010-02-10
Posts: 33

Re: zem_contact_reborn 4.0.3.20

@ruud Yup, that was it! Thanks a lot.

Offline

#1126 2012-01-19 23:27:57

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 180
Website

Re: zem_contact_reborn 4.0.3.20

Hi to all! Is this possible?

<txp:zem_contact_secret value="<txp:title />" />

So I could receive the Title of the page that was send from.

Thanks in advance!

(PS. Sorry bad English)


—-
ONE is LOVE

Offline

#1127 2012-01-20 00:38:15

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,085

Re: zem_contact_reborn 4.0.3.20

Try single quotes around txp:title: <txp:zem_contact_secret value='<txp:title />' />


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#1128 2012-01-20 02:46:27

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 180
Website

Re: zem_contact_reborn 4.0.3.20

Hey @uli Thanks a lot!


—-
ONE is LOVE

Offline

#1129 2012-02-01 14:53:17

castanet
Member
From: Oxford
Registered: 2005-03-19
Posts: 97

Re: zem_contact_reborn 4.0.3.20

This is probably simpler than I think it is, but all my articles have a contact form and I want the subject line to be the title and/or the id of the article.

I have tried <txp:zem_contact to=“me@home.co.uk” subject=”<txp:page_title />” label=”“> but to no avail.

This isn’t to send articles to other recipients, just to me.
Thanks in advance for any guidance.

Offline

#1130 2012-02-01 14:59:23

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,085

Re: zem_contact_reborn 4.0.3.20

That’s the same issue as two posts above: use single quotes around nested TXP tags.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB