Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#841 2010-07-27 12:15:19
Re: zem_contact_reborn 4.0.3.20
funtoosh wrote:
i am using an individual contact-page, and all articles i have describe team members — the title referring to their name, and a custom field specifying their email address. the contact form should generate its dropdown from the articles’ txp:title’s and txp:custom_field’s.
ruud, thanx for pointing me into the right direction — unfortunately, my knowledge of php is fairly limited, so it’s taking me a while to debug & finish the code.
but i guess we’re getting there, albeit slowly, slowly. i suppose the idea of having a custom contact form as described above might be of use for other people as well, so there’ll be no harm in documenting the case here.
ruud wrote:
Okay. I assume the dropdown list in the contact form is already working and filled automatically with all those team member article titles, right?
yep, it is.
In the PHP code, you’d have to query the textpattern table to get the custom field for the article title selected by the visitor in the contact form. The
safe_field
function should help you do that:
$email = safe_field('custom_1', 'textpattern', "title='".doSlash($title)."'");
if (empty($email) or !is_valid_email($email)) $email = 'default@example.com';
Note that $email will be set to FALSE if the article title isn’t found. And This assumes that the user selected title is stored in the $title variable
… so i’d have to use a safe_field
for the title as well, right? how do i manage sorting the titles? they should be sort="Category1, Posted asc"
the code now looks sth. like this:
<txp:zem_contact label="" to_form="*dropdown*">
<txp:zem_contact_text label="Name" /><br />
<txp:zem_contact_email /><br />
<txp:zem_contact_select label="Adressat" list="*,<txp:article_custom limit="100" sort="Category1, Posted asc*" form="F-teamselect" />" /><br />
<txp:zem_contact_textarea label="Message" /><br />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
and in dropdown:
<txp:php>
global $zem_contact_form;
switch($zem_contact_form['Adressat'])
{
$title = safe_field('title', 'textpattern', '??');
$email = safe_field('custom_2', 'textpattern', "title='".doSlash($title)."'");
if (empty($email) or !is_valid_email($email)) $email = 'default@example.com';
}
</txp:php>
Offline
#842 2010-07-27 16:02:06
Re: zem_contact_reborn 4.0.3.20
Your ‘Adressat’ dropdown allows visitors to select an article title (right?), so in your “dropdown” form you already know which title the visitor selected. All you want to know is which email address was filled out in the custom field (#2, so it seems) for that article:
<txp:php>
global $zem_contact_form;
$email = safe_field('custom_2', 'textpattern', "title='".doSlash($zem_contact_form['Adressat'])."'");
if (empty($email) or !is_valid_email($email)) $email = 'default@example.com';
echo $email;
</txp:php>
Offline
#843 2010-07-27 17:12:04
Re: zem_contact_reborn 4.0.3.20
ruud schrieb:
Your ‘Adressat’ dropdown allows visitors to select an article title (right?)
exactly!
so in your “dropdown” form you already know which title the visitor selected. All you want to know is which email address was filled out in the custom field (#2, so it seems) for that article:
still, there seems to be a problem with the title, selecting any of the titles in the dropdown does not seem make the form know $title.
the above code throws up a Sorry, unable to send email.
and when i use dmp($email);
i get:
Error in tag: <txp:php> -> Notice: Undefined index: Adressat on line 3
and dmp($title);
returns:
Error in tag: <txp:php> -> Notice: Undefined variable: title on line 6
sorry, i really didn’t expect this to be that difficult ;—(
Offline
#844 2010-07-27 18:14:37
Re: zem_contact_reborn 4.0.3.20
Not sure if somehow related with your current issues, but this:
<txp:zem_contact_select label="Adressat" list="*,<txp:article_custom limit="100" sort="Category1, Posted asc*" form="F-teamselect" />" />
Should be:
<txp:zem_contact_select label="Adressat" list='*,<txp:article_custom limit="100" sort="Category1, Posted asc*" form="F-teamselect" />' />
(use single quotes when nesting txp:tags inside other txp:tags)
edit: fixing some textile errors, doh!
Last edited by maniqui (2010-07-27 18:16:05)
Offline
#845 2010-07-27 18:49:45
Re: zem_contact_reborn 4.0.3.20
ojeh, this is SO embarassing … the single quotes seem to have caused the problem!!
¡gracias a maniqui!
Offline
#846 2010-07-31 13:43:12
Re: zem_contact_reborn 4.0.3.20
… and, just for posterity’s sake, i thought i should add the other customization of ZCR i’ve used for the same site:
below every entry for a team member, there is a link to a personalized mail form, like this:
<a href="/mail?to=<txp:article_url_title />" title="Mail form for <txp:title />">Contact</a>
… in the page template:
<txp:zem_contact label="" to_form="mailform-byrequest">
<txp:zem_contact_text label="Name" /><br />
<txp:zem_contact_email /><br />
<txp:zem_contact_textarea label="Message" /><br />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
… and, finally, “mailform-byrequest”:
<txp:php>
global $zem_contact_form;
$email = safe_field('custom_2', 'textpattern', "url_title='".doSlash($_REQUEST['to'])."'");
if (empty($email) or !is_valid_email($email)) $email = 'test@example.org';
echo $email;
</txp:php>
in which custom_2
contains the mail address. instead of article_url_title (here: url_title
) one might as well use article_id (id
), i just thought, the url title would be more semantic, as it gives me more comprehensible urls (e.g. “/mail?to=mr-funtoosh”).
whole thing could be of good use if you want to avoid publishing all email addresses for reasons of spam protection.
cheers, -f
Offline
#847 2010-07-31 17:37:09
Re: zem_contact_reborn 4.0.3.20
guys, is this plugin support attaching files for send to email?
<txp:txp_me />
Offline
#848 2010-07-31 17:43:54
Re: zem_contact_reborn 4.0.3.20
Katalonian wrote:
guys, is this plugin support attaching files for send to email?
Hi Ziya, No it doesn’t but there is a plugin, Anonymous File Upload
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#849 2010-08-11 07:29:41
- jacyperks
- New Member
- Registered: 2009-04-16
- Posts: 8
Re: zem_contact_reborn 4.0.3.20
Hi There,
I wonder if there is some who can help out there? I am trying generate the options for a select field from the titles of articles in a specific section with no success.
I am using the following:
- Textpattern – 4.0.5
- Zem_Contact_Reborn – 4.0.3.20
- zem_contact_lang – 4.0.3.6
I have tried the following two methods, neither of which work.
Method 1: Using a custom_article tag with in the zem_contact_select tag
<txp:zem_contact_select label=‘xyz’ list=’<txp:custom_article display=“999” form=“optionlist” />Other’ />
The form is simply as follows:
<txp:title />,
The above code break and doesn’t generate anything useful.
Method 2: I code the field out in HTML and use a custom_article tag to generate the list of options.
<select id=“xyz”>
<txp:custom_article display=“999” form=“optionlist” />
<option value=“Other”>Other</option>
</select>
The form is as follows:
<option value=”<txp:title />”><txp:title /></option>
This generates a select filed with all the right options but when you send the form this field does not appear in the received email.
Can anyone help me get one of these methods to work please? Many Thanks in advanced.
PS – I have tried maniqui suggestion using single quotes and that doesn’t work for me. Here is my exact code:
<txp:zem_contact_select label=“Label” list=’<txp:article_custom limit=“999” section=“section” sort=“Title asc” form=“dropdown-list” />Other’ />
And the form is as follows:
<txp:title />,
I get a dropdown that strangely says “General Inquiry” and then “Other’ />” directly after that.
Last edited by jacyperks (2010-08-11 08:54:48)
Offline
#850 2010-08-11 09:43:49
Re: zem_contact_reborn 4.0.3.20
hi jacy, try this:
<txp:zem_contact_select label="xyz" list='<txp:article_custom limit="999" form="optionlist" />Other' />
not sure if you can use display
in this context.
Offline
#851 2010-08-11 09:56:31
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: zem_contact_reborn 4.0.3.20
jacyperks
You can’t nest tags in txp 4.05. This feature was introduced in txp 4.07
Offline
#852 2010-08-11 10:05:19
- jacyperks
- New Member
- Registered: 2009-04-16
- Posts: 8
Re: zem_contact_reborn 4.0.3.20
That doesn’t seem to work either. I still get a dropdown that strangely says “General Inquiry” and then “Other’ />” directly after that.
Thanks for responding though.
Offline