FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Best method for adding contact form to multiple pages?

Feed 4 posts, 3 voices

Avatar
96 posts

I need to add a contact form to dozens of pages. Each form is generic – just name, email, phone and enquiry.

I’ve started using ‘Email template’, but it’s a bit of a chore adding 1 page part + 3 children (template, success, failure) for every form.

Can anyone recommend a better plugin / method for what I’m doing?

 
Avatar
1493 posts

Hi David: One thought that comes to mind is inheritance-through-page-parts.

Much depends on whether all these pages are children of the same parent.

But if they share a common parent, then that parent can include a page-part containing the contact form, :) and you’re away. You would want to hide it on the parent page, I’m guessing. If so something like this might work:

<?php if ($this->level() > '2') { $this->content('contact_form', true); } ?>

Of course, I’m just guessing which “level” you might want to hide this from, of course.

Update: I’ve just clocked that you’re using tuupola’s email form; of course, the method I’m suggesting here would need e.g. tb_contactform.

Update #2: And of course I’ve just remembered that each page would need a unique email address for every individual page… So maybe this idea sucks. :) I’ll leave it here, both as a record of my stupidity which may serve as a warning to others, and also on the off chance it might inspire a solution that actually works.

 
Avatar
1493 posts

I’m frantically busy doing something else, so naturally this came back to mind…

A glimmer of an idea inspired by Craig’s solution for multilingual titles:

  • have your list of contact names in the parent page — perhaps with the link made by number or code that gets stored in a session variable;
  • on the contact form page, have a page-part devoted to listing ALL the separate contact info, each on a given line;
  • use Craig’s technique combined with that session variable to pull out and store the relevant data for that particular person;
  • shove it into the one, single contact form using PHP.

So the links might look like this:

<a href="cb">Charlie Brown</a>
<a href="lp">Linus van Pelt</a>
<a href="oo">Olive Oyl</a>

And the page part could have a comma-delimited list (or something):

cb,Charlie Brown,chasbown@example.tv,321 4567
lp,Linus van Pelt,lvpelt@example.tv,321 5678
oo,Olive Oyl,olive@example.tv,321 6789

And your preg-match routine (see example from “multilingual titles” link above) stores them into variables that then get plugged into the single contact form.

Will it work? Craig’s been working hard today already, I noticed, but maybe he can opine whether this is a rubbish idea, or whether it might have a future.

I don’t know if that would work, but thought I’d toss it out there, just in case it has any merit.

If it does work, it would make it pretty easy to keep updated…

 
Avatar
291 posts

I’ve started using ‘Email template’, but it’s a bit of a chore adding 1 page part + 3 children (template, success, failure) for every form.

There is no need to add three templates or success and failure pages. Only one of each is enough. Each form can use same template and success or failure page.

 
Avatar
96 posts

Hi David,

Thanks for the suggestions – although looks like I’m not going to use any of them (see reply to tuupola) – but they certainly help wedge a little more ‘Froggy Thinking™’ in to the cranium. ;) Although, I’m going to go back and quickly try tb_contactform again after your suggestion – I did try it a few months ago and didn’t get on with it for some reason – can’t remember what it was now.

~~~

tuupola,

D’oh! Of course! :) That makes it much easier. Thank you.