1

Full disclosure; I'm a complete newbie to Drupal development.

I've been tasked with embedding a contact form in the footer component of our site's template. I've been told to use the Drupal Contact module for this task. The problem is, I don't see how this is possible without dramatically altering the contact module itself. Is there any way to embed the Drupal Contact Module's form in a template; rather than have it as a standalone page? Any constructive input is greatly appreciated.

I'd also be open to any other way of embedding a form directly in a Drupal template.

Thanks, Frank

Frank Rosario
  • 2,512
  • 5
  • 31
  • 47

2 Answers2

0

Frank, The following worked for me, I placed it directly in my template.

require_once drupal_get_path('module', 'contact') .'/contact.pages.inc'; print drupal_render(drupal_get_form('contact_site_form'));

source

makbeta
  • 339
  • 3
  • 5
0

You should be able to accomplish that by adding the following code into your theme's template.php file:

function mytheme_preprocess_page(&$variables) {
  module_load_include('inc', 'contact', 'contact.pages');
  $variables['contact_form'] = drupal_get_form('contact_site_form');
}

Then in your page template file(s) you can output it with the following code snippet:

<?php print render($contact_form); ?>

Don't forget to replace 'mytheme' with your actual theme's name and clear the caches.

Madis
  • 283
  • 1
  • 4
  • 11