I want to use drupal 7 core module for contact.
I want to use it as block so that I can add a contact form to the right sidebar of your website which should be shown at every page. or render it anywhere in the page
I saw this on drupal site and tried to use it.

print drupal_get_form('contact_mail_page');

It is showing me this

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'contact_mail_page' not found or invalid function name in drupal_retrieve_form() (line 841

So any suggestion how I can use this.


use this code

if(!function_exists('contact_site_page')) {
  require_once drupal_get_path('module', 'contact').'/contact.pages.inc';
  $output = drupal_get_form('contact_site_form');
  print drupal_render($output);

and put print drupal_render($output); where ever you want to put the contact form.

as another solution you can also assign a region for where you want the contact form to be then place the form in there.

  • 2
    This should work. Just once change to make is more bullet proof, require_once could be replaced by module_load_include('inc', 'contact', 'contact.pages');
    – AjitS
    Jun 8 '14 at 13:09
  • 1
    @AjitS there exists many ways, just try them ;)
    – M a m a D
    Jun 8 '14 at 13:12
  • 3
    @Drupalist module_load_include() is the preferred method for including module files
    – Clive
    Jun 8 '14 at 13:13
  • thank you very much.... You guys are genius.... thank you @AjitS... Please tell me about another solutions also how to do with region
    – Amrita
    Jun 8 '14 at 14:20
  • @Clive yes you are right. there is something I was going to ask you about your website. I saw your slide called deckslide, what is it? a module or you built it?
    – M a m a D
    Jun 8 '14 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.