Drupal: One web form for each product.
Are you using the Drupal webform.module to get visitor feedback? Do you want to indicate in the webform, from where the visitor chose to contact you? Here you go.
Let's suppose that the site has many products and the visitor can request additional information on each product, directly from the product node. It will be helpful if the product name is automatically included in the web form when submitted by the user.
Here's how to do it.
- Create some product nodes with CCK
- Create the web form with webform.module
- include the fields that the user completes.
- include the product field to be filled automatically.
- set the product field default value to
%get[product] - Create a block that adds a link to the web form to a page
- put the link to the web form in the block body
<a href="inforequest?product=<?php print drupal_get_title() ?>">Request more information regarding this product.</a> - the first portion creates the link to the web form node, called inforequest
<a href="inforequest - the next portion passes the variable name into the url and prepares it for a value
?product= - the next portion assigns the node-title value to the product parameter
<?php print drupal_get_title() ?> - then close the open-href tag, add the link text and close the a-tag
">Request more information regarding this product.</a> - Make the block visible only for the product content type
<?php
$match = FALSE;
$types = array('product' => 1);
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$match = isset($types[$node->type]);
}
return $match;
?> - Test


Articles © 2010
Map images and data © 2010