Hello, everyone,

I'm a Drupal newbie (converting from Joomla, but that's another story) and need assistance or ideas of how to get a contact form at the bottom of each page and story. Ideas that I've explored:

- Use the Comments function, but the email notice should go to directly to one of about 50 volunteers. Besides we don't plan to publish any of the "comments," so that doesn't seem right.

- Set up 50 different categories using the Contact Form module, extended with the Contact_List module, then link to the appropriate Contact Form page by hand from each story. This is what I'm currently doing, but it is tedious and kind of clunky.

- Add the related Contact Form at the bottom of each page as a block - heck, I'd be happy even with the generic Contact Form at the bottom of each page as a block. But I can't figure out how to do this, despite searching and searching this site.

- Use the Feedback module. This seemed like an option, but it seems to be just like the Contact Form in that it links to a separate page. I cannot find an example of how this really works.

The purpose is to make it easier for visitors to ask questions about the various ministries at our parish. I am open to other, easy-to-use ideas. I don't want to do any custom code edits because this will be turned over to the parish staff to administer after I get it set up. Thanks for your ideas!

Happy day,
Anne

Comments

pwolanin’s picture

I posted a PHP block snippet for doing this here: http://drupal.org/node/73973

Also, do you have some way of easily determining which contact category is appropriate for each post? For example, a taxonomy term? If so, you could implement a tiny custom module that uses hook_link to automatically add a link to the bottom of each post to the appropriate contact form. For examples for how to write a little module, see the mini module snippet section

---
Work: BioRAFT

Anonymous’s picture

Okay, I tried your code, but it didn't work for some reason. But I went into the contact module and pulled the code and made a custom block that will insert the form. Yoo hoo!

The only problem is that I'm also trying to use Contact_list (so that we have a contact/email directory). So far, I can't seem to use both the custom block and Contact_list at the same time. If I try to activate the contact_list module with the custom block active, the page won't load, so I figure that bad things are happening behind the scene, cancel out and deactivate one of them. You're welcome to take a look http://70.47.125.114/. It is definitely a work in progress!

Minimodules and hook_links are beyond my capabilities at this time. :-) It would be cool to have the contact form categories automatically link to the taxonomy!

Happy day,
Anne

pwolanin’s picture

I'm also using the contact list module. Make sure the block is set to PHP format, etc. Here's the exact block code I'm using:

/* NOTE- this block code requires the contact module.
   e-mail will be direct to the default (selected) contact, or if none is selected it will be directed to the contact with the lightest weight.

*/


function quickcontact_form() {
  global $user;
  
  if ($user->uid) {
    $edit['name'] = $user->name;
    $edit['mail'] = $user->mail;
  }

  $default_category = 0;
  
  $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');

  while ($category = db_fetch_object($result)) {   
    if ($category->selected) {
      $default_category = $category->cid;
    }
    elseif (!$default_category) {
      $default_category = $category->cid;
    }
  }

  if ($default_category > 0) {
    $form['#token'] = $user->name . $user->mail.'quick';
    $form['name'] = array('#type' => 'value',
      '#value' => $edit['name'] ? $edit['name'] : 'Guest',
    );
    $form['mail'] = array('#type' => 'textfield',
      '#size' => 20,
      '#maxlength' => 80,
      '#default_value' => $edit['mail'],
    );
    $form['subject'] = array('#type' => 'value',
      '#value' => 'via example.com',
    );
    $form['cid'] = array('#type' => 'value',
      '#value' => $default_category,
    );
    $form['message'] = array('#type' => 'value',
      '#value' => 'Please add me to the e-mail list',
    );
    $form['copy'] = array('#type' => 'value',
      '#value' => FALSE,
    );
    $form['submit'] = array('#type' => 'submit',
      '#value' => 'Submit e-mail address',
    );
    $output = drupal_get_form('quickcontactblock_form', $form,'contact_mail_page');
  }
  else {
    $output = t('The contact form has not been configured.');
  }
  return $output;
}


print quickcontact_form();

make sure you don't re-use function names from the contact module- maybe that's why it breaks.

---
Work: BioRAFT

Anonymous’s picture

Thanks so much. I think that's the code I was using. It didn't "break" it so much as it didn't recognize the categories, so it was just putting up some fields from what is apparently an email newsletter sign up form.

I consulted with the client, and they prefer the regular contact form, and NOT the Contact List. So the block I created will work fine.

To restate for those following along -- I created a PHP block that is now activated in the content area on "front end" pages. It is essentially a copy from the contact module, edited to create a contact_mail_block.

Back to working on the theme and adding content pages!

Happy day,
Anne

alex_stanhope’s picture

I've posted a 5.2 solution here:

http://drupal.org/node/166432#comment-266492

Alex Stanhope
Lightenna