Drupal Simplied Contact form

A site I'm working on has a simple contact us form in the footer of every page. I didn't want the long drawn out contact form with all the name, subject, email, message fields. Here is what I did.

Installed the formblock module

Easy enough, install the module, enable the block so that the contact form now shows in the footer.

Simply the contact form

Now we want to hide some of the fields in the contact form.

In your template.php file, you'll want to add the following lines.

function basic_theme(){
  return array(
    'contact_mail_page' => array(
      'arguments' => array('form' => NULL)
      )
    );
}
 
/**
 *  Hide and autofill some fields in the contact form.
 *
 */
 
function basic_contact_mail_page($form){
 
  $form['subject']['#value'] = "Website question";
  $form['subject']['#type'] = 'hidden';
  $form['name']['#type'] = 'hidden';
  $form['name']['#value'] = 'Website Customer';
  return drupal_render($form);
}

As you can see I'm using the Basic theme from Drupal. If you're using a different theme you'll want to change the word basic to your own theme (e.g. blueprint).

Now you have a simple contact form.

drupalcontact.png

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <javascript>, <php>, <sql>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options