Feedback on a custom contact form

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.

Login to post comments

Prepopulate

ebrittwebb's picture
ebrittwebb - Tue, 2009-02-24 05:37

Have you tried using Prepopulate?


Nope. I'll check it out

mattmm's picture
mattmm - Tue, 2009-02-24 13:10

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

matthewm.org


Cool

EssMark - Fri, 2009-09-04 12:14

Cool, I'll checking this out also.

Coach Hire Birmingham


Prepopulate and Location

bittennails - Tue, 2009-02-24 16:10

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
mattmm - Tue, 2009-02-24 16:12

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
gestaltware - Tue, 2009-02-24 19:30

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

J. Cohen's picture
J. Cohen - Wed, 2009-03-04 20:01

Is that done with the Workflow Module?

--
My Drupal Tutorials


Yes I was thinking of going

mattmm's picture
mattmm - Tue, 2009-02-24 20:15

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

allgoodthings's picture
allgoodthings - Wed, 2009-02-25 00:46

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
mattmm - Wed, 2009-02-25 00:52

We were Drupal ninjas for a day!

matthewm.org


Hi, What is the best solution

Summit - Thu, 2009-11-05 13:05

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 - Thu, 2009-11-05 17:12

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