Feedback on a custom contact form

Events happening in the community are now at Drupal community events on www.drupal.org.
mattmm's picture

Looking for some help/ideas on a custom contact form. Webform displays a token %title to pass, what i'm assuming is, the node title. However, it dosn't seem to be working correctly. I've posted a support question on the project page. So i'm looking to pass either the node title or node url of a webform that I have embedded in a block on said node.

Has anyone acheived passing custom tokens/arguments in a webform? Even further any luck passing custom cck fields in a webform or just a standard node that dosn't get published but e-mail via actions/triggers?

Any help would be appreciated.

Comments

Prepopulate

ebrittwebb's picture

Have you tried using Prepopulate?

Erik Britt-Webb
drupal@ebrittwebb.com

Nope. I'll check it out

mattmm's picture

Nope. I'll check it out though - thanks!

matthewm.org

Cool

EssMark's picture

Cool, I'll checking this out also.

Coach Hire Birmingham

Prepopulate and Location

bittennails's picture

Seems to be an issue between Prepopulate and Location though, and fieldgroup issues abound which we are using on the nodes in question. Quick test on a localhost and nada so far...

Yea, I don't think this will

mattmm's picture

Yea, I don't think this will be the answer for us. There has to be a way to pass the variables that dev render can see on a node into the results of a webform...

matthewm.org

Don't use webform

gestaltware's picture

I wouldn't recommend Webform. Stick with a CCK-based solution augmented by workflows, actions, and optionally views. It's standard now and the huge advantage of this is that the inquiries become part of the site, not resulting in a separate storage silo (email inbox) or having tracking issues when there is more than 1 administrator (whether or when the inquiry was answered).

  1. create a Contact nodetype
  2. add some fields to it (From, Subject, Comment, anything else you want)
  3. enable create access permissions for the node type for anon and auth users
  4. use one of the many access control modules to view the node: one example would be to assign a workflow to the node and then use Workflow Access to only allow admins (and possibly the author if she was a a registered user when creating the inquiry) to view the node
  5. add send email as an action to the workflow state from creation -> Submission

(optional)

With this as a base, you can do (as I have done on various projects) a lot more.

You might use the Comment Dialogue module I wrote to enable an ongoing discussion between the original author and a role group (Site admins).

You could have the inquiry nodes listed on the user's profile to track.

You could embed the user registration form into the inquiry for anonymous users.

You could fire any number of actions based on time-elapsed from a workflow transition (e.g. follow-up emails).

...etc.

Good luck.

Workflow

Z2222's picture

Is that done with the Workflow Module?

--
My Drupal Tutorials

Yes I was thinking of going

mattmm's picture

Yes I was thinking of going CCK/Actions/Triggers route to get that done. I do like your idea of workflows and introducing time elapsed or not responded to etc.

At this point I will think somethign like that through for version 2.0 of the project. ;)

Right now, I have product page (node) with a "contact me about this product" form (webform in a block in a quicktab) at the bottom and I simply need the form to submit an email that says which product (or node page/url) it came from so the recipient knows what product the user wants to be contacted on. Also included in the form is Name, e-mail, and question fields supplied by the user.

matthewm.org

webform email tweak

cheese-steak's picture

The workflows sounds like the best long-term.

In the short-term, bittennails found that setting the default value of a hidden form element to the token %get[q], it passes the node location or 'node/45' which worked great.

Webform has templates you can copy to your theme directory (see theming.txt in module folder for specifics).

I edited the email tpl file to explode() the node/45 string to get just the node id, then ran a query to grab the node title to display in the email. ('select title from node where nid = ' . $justnodeid;)

In addition to the themes.txt and the help in the tpl file itself, I found putting print_r(get_defined_vars()); helpful in finding how to call that specific submitted element.

Being very new to drupal, I'd be interested in how many guidelines I've broken by doing this.

Inserted into webform-mail.tpl.php:

<?php
print t(' '); //extra line for formatting
?>

<?php
// passed item id from webform in form of 'node/45' - separating node/ from 45.
 
$itemarry = explode("/",$form_values['submitted']['5']);
 
$itemnode = $itemarry[1]; //taking just the numerical value (like 45) to run the query.

 
$sql = 'SELECT title FROM {node} WHERE nid = '.$itemnode;
 
$results = db_query($sql); // Run the query
 
while ($title = db_result($results)) { // there should only be one...
   
echo " Item Title: ".$title." - http://linktomysite.com/".$form_values['submitted']['3'];
  }
?>

We were Drupal ninjas for a

mattmm's picture

We were Drupal ninjas for a day!

matthewm.org

Hi, What is the best solution

summit's picture

Hi, What is the best solution right now to have a form with fields, which could be emailed as a contact form by the user?
Thanks a lot in advance for your reply!
greetings,
Martijn

Martijn, have you looked into

Garrett Albright's picture

Martijn, have you looked into Webform? It can be used to build contact forms with customizable fields.

Not email function working..

rituraj.gupta's picture

Hi,
I am using drupal 6.12. Webform is best for creating form as u like.but one issue with this that when a user submit the webform, all details send to administrator but a copy don't send to user. How this problem can resolved? i want to submit all user details to admin as well as a copy also send to user email? should i use another module instead of webform module? make it clear asap.

Regd's
Ritu Raj

In Webform, if you create a

RobW's picture

In Webform, if you create a form component with the type "email" there is a checkbox for "E-mail a submission copy". Checking this will email a copy of the form results to the address in that field.

If your site has registered users there is also a checkbox called "User email as default" which automatically fills this field with the registered user's email.

And conditional emails as well

ablewave's picture

Webform will also let you set conditional emails based on the form input. For example, if your field "inquiry type" is "Send me a brochure", you could send a copy of the form or just the relevant part to the person in charge of sending brochures.

Webform gets knocked sometimes because its results aren't nodes and thus can't be exposed to Views, but if used for the purpose for which its built I have found it to be a lifesaving mod.

Conditional Emails How-to?

nelslynn's picture

Could some please explain how to do this with Webform? I would like the same functionality as Contact Form where you can have a "Category" select box, and send the results of the webform to an email address based on what the user selected for "Category".

I cannot seem to find out how to do this.. any help is appreciated.

Another solution with Session

stevenx's picture

I used the Body Field of the webform with input format PHP Code to save the required values of the Node in a Session

<?
// Get the NODE Title
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$_SESSION['mytitle'] = $node->title;

}

?>

Than i used the webform-mail.tpl.php and simply print out the session variable I need

<? print_r($_SESSION['mytitle']); ?>

drupal theme development

George - Go2Hire

source4india's picture

Hey

Webform is Good . You need to use with Captcha and Jquery Validation

Don't use contact form module when you use webform module .

because sometime execution mesh up , you will get blank Page .

Regards
George
ceo@Go2Hire.com
http://Go2Hire.com

Boston

Group categories

More Specifically

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: