Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2007-03-08 20:41:08

lreynolds
Member
From: Burlington, ON, Canada
Registered: 2007-02-09
Posts: 30
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Is it possible to include txp tags inside the ZCR tags? I want to populate a select box with the names of the current projects. The projects on this page are editable by the client, and I want visitors to be able to request updates about one of the projects listed. I tried this: <txp:zem_contact_select list="<txp:article form="titlecomma" status="live" limit="5" sort="Posted desc" />" label="New Projects" name="new" required="no" break=""/> but it doesn’t work. The form titlecomma contains a comma and a title tag.

If this is not possible, is there another way of doing this?

Offline

#50 2007-03-08 20:49:34

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)

It’s possible by using asy_wondertag
The textpattern FAQ explains another way to do this.

Last edited by ruud (2007-03-08 20:54:21)

Offline

#51 2007-03-09 16:54:28

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Ruud,
I’m separating zem_contact into two divs, and seeing that the form is ending before I specify. Is this a bug? See below:
The form is closing after the first unordered list. Any thoughts?
see something in my code I overlooked?

EDIT I note now, that if I place the zem_contact opening and closing tags fully outside the .left and .right divs I am able to close it properly. Still may be a bug though?

<div class="left">
				<div class="post">
					<h3>Request a Proposal</h3>
					<p>Are you interested in working with Squared Eye Design? This is the place to start. Fill out the basic form below. As soon as I give it a read through, I'll be in touch.</p>
					<h3>RFP Form</h3>
					<txp:zem_contact to="email@address.com" thanks_form="contact_thanks" >
					<ul class="contact">
						<li><txp:zem_contact_text name="name" label="Your Name" required="1" break="" /></li>
						<li><txp:zem_contact_email  name="email" label="Your Email" required="1" break="" /></li>
						<li><txp:zem_contact_text name="business" label="Your Business or Organization" break="" /></li>
						<li><txp:zem_contact_text name="web" label="Your Website" break="" /></li>
						<li><txp:zem_contact_text name="telephone" label="phone" min=7 max=15 break="" /></li>
					</ul>
				</div><!--/post-->
			</div>
			<div class="right">
				<div class="post">
					<ul id="rfp_details">
						<li><txp:zem_contact_select name="size" label="How Big is Project?" list="Choose a size, Just a homepage, A small personal website (3-5 pgs), A small business (10-15 pgs), Getting bigger (20-30pgs), I'm really not sure yet" required="1" break="" /></li>

						<li><txp:zem_contact_select name="services" label="What Types of Services Do You Need to Employ?" list="Choose a type, Just layout design, Design and coding (XHTML + CSS), Design and coding plus a content management system (CMS), I need some help figuring out this part" required="1" break="" /></li>

						<li><txp:zem_contact_select name="budget" label="What is Your Budget for This Project?" list="Choose a budget, Less than $500, $500-$1500, $1500-$4000, $4000-$10000, Sky's the limit!" required="1" break="" /></li>

						<li><txp:zem_contact_select name="timeline" label="What is Your Timeline for This Project?" list="Choose a timeline, Less than 2 months, 2-4 months, 4-8 months, 8-12 months, Before the next ice age" required="1" break="" /></li>

						<li><txp:zem_contact_textarea  name="notes" label="Additional Notes" break="" /></li>

						<li><txp:zem_contact_submit label="Send" /></li>
					</ul>
					</txp:zem_contact>
				</div><!--/post-->
			</div>

Last edited by ma_smith (2007-03-09 17:35:44)


Offline

#52 2007-03-09 17:09:52

lreynolds
Member
From: Burlington, ON, Canada
Registered: 2007-02-09
Posts: 30
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

That’s great, thanks so much for the help.

Offline

#53 2007-03-09 18:18:34

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)

Matthew, it’s not a bug. Look at the HTML source of the page that TXP generates. You’ll see that the tags are not nested properly. I’m guessing the </div> tags cause the HTML parser in the browser to implicitly close the form tag.

Offline

#54 2007-03-09 21:14:38

frodriguez
Member
From: Tampa, FL
Registered: 2007-03-09
Posts: 11
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Here is a little modification I wrote to avoid double errors for required values. Maybe someone will find it helpful if they are looking for the same result. I think the comments do a good job of explaining the thoughts behind the mod.

I did notice that when I made another required text field and put in some white space(s) the required error went away which is something I don’t want happening, so
I will probably add a similar clause under the zem_contact_text() function call as well. This may be something that has already been addressed, or easier to fix then going to code, so if that is the case then if someone can point me to an easier solution it would be appreciated. I just recently installed this plugin and may have missed it

function zem_contact_email($atts) {
	global $zem_contact_error, $zem_contact_form, $zem_contact_from;
	$atts = array_merge(array('label'=>'Email', 'required'=>'1'), $atts);
	$label = (empty($atts['label']) ? 'Email' : $atts['label']);
	$name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);

	if (ps('zem_contact_submit')) {
		$email = ps($name);
//-----------------------------------------------------------------------------------
// If a field is required and empty or blank, then avoid outputting a double error 
// (required and invalid error), just show required error.
//-----------------------------------------------------------------------------------

// Test to see if we have no string value or a bunch of white-space
// characters which is still semantically empty
		if ( preg_match('/^\s*$/', $email) ) {

// Manually make empty so the zem_contact_text* functions will 
// register the empty errors later
// the post key had already been set so we can safetly modify it here directly
			$_POST[$name] = '';

		} else {
//-----------------------------------------------------------------------------------

		if (!preg_match('/^[\w._-]+@([\w-]+\.)+[\w-]+$/', $email))
			$zem_contact_error[] = "'$email' is not a valid email address";
		elseif (preg_match("/@(.+)$/", $email, $match)) {
			$domain = $match[1];
			$mx = 0;
			if (is_callable('getmxrr')) {
				$dummy = array();
				$mx = @getmxrr($domain, $mx);
			}

			if (!$mx and (@gethostbyname($domain) == $domain))
				$zem_contact_error[] = "Domain '$domain' is not a valid email host";
			else
				$zem_contact_from = $email;
		}
		else
			$zem_contact_from = $email;

//-----------------------------------------------------------------------------------
		}
//--------- END OF MOD --------------------------------------------------------------

	}

	return zem_contact_text($atts);
}

Offline

#55 2007-03-09 21:55:02

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)

Good idea, ignoring the whitespace.
Would anyone object if the next ZCR version stripped leading and trailing whitespace/newlines from the input values?

PS. Using the PHP ‘trim’ function in _text and _email is shorter.

Last edited by ruud (2007-03-09 21:56:36)

Offline

#56 2007-03-09 22:06:50

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

ruud,
thanks :) I could have looked harder, must have been blinded by ‘parent of infant – no sleepy’ syndrome.

per the ZCR next version, what’s the downfall of stripping the whitespace? Any?

What about adding a class to preview and submit, accordingly? This could allow (only using CSS1) to specify a different style to the submit button to highlight it for instance.

Also, I’ve been working on trying to get zem_contact to submit using Jquery AJAX, and getting help from Hakjoon (who is busy :), would anyone be up to working on that together? (the application for me is useful since I keep several contact forms inside toggling divs). This might be a fun little project to do on the side for the community. I’m not much of a JS coder (yet!), but I can test and cut and paste like nobodies business!

:)

Matthew


Offline

#57 2007-03-09 22:09:41

frodriguez
Member
From: Tampa, FL
Registered: 2007-03-09
Posts: 11
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

That is a good suggestion, however the regex will catch white space that is inputted in succession, so if an input value
had a leading whitespace, some content and then trailing whitespace or newlines they wouldn’t be affected, so it would preserve the formatting of text areas and the like. So if someone puts a double blank in a field just to bypass a required field or wants to just put garabage in your db (as is the case with postmaster which is what is currently utilizing this plugin) it would catch it.

I was mainly focusing on the email portion which is more of a personal choice to not output two errors when a field is just blank and it is required, not sure if this is something that you want to implement across the board as some might like that it reports invalid as well as required.

Last edited by frodriguez (2007-03-09 22:12:55)

Offline

#58 2007-03-09 22:30:10

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)

Federico, I think trim doesn’t affect formatting of the textarea very much, because the textarea input is treated as one single chunk of text. I can’t think of a situation where empty space or linebreaks at the beginning or end of a textarea are relevant or desired.

Btw, I don’t see two errors on the email field if I just enter whitespace. Only the ‘invalid email’ error is shown.

What about adding a class to preview and submit, accordingly?

Matthew, there is already a class for the submit button (zemSubmit). There is no preview button.

Last edited by ruud (2007-03-09 22:37:11)

Offline

#59 2007-03-09 22:35:53

frodriguez
Member
From: Tampa, FL
Registered: 2007-03-09
Posts: 11
Website

Re: zem_contact_reborn 4.0.3.19 (old version)

Well no, the 2 errors I was referring too was if you enter nothing then you get one error for “ Invalid Email ‘’ ”
and then another for the email being required. I only wanted to see the required error if someone entered nothing.

Offline

#60 2007-03-09 22:39:58

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)

Federico, looking at the code you posted above, I think you’re using zem_contact instead of zem_contact_reborn (ZCR). They are two different plugins. The ZCR 4.0.3.19 version doesn’t show two errors.

Last edited by ruud (2007-03-09 22:44:33)

Offline

Board footer

Powered by FluxBB