How do I put Drupal's sitewide contact form on any page or panel I want?
Is Drupal's default contact form page a tad too restrictive? Do you want to have more than comfortably fits in the little option to have some text above the contact form? Do you need even that text to be multilingual? Would you rather not try to do all this with form_alter and creative use of blocks? Why can't one simply embed the contact form in a page, or better yet as one element in a panel, you ask? Why, indeed. Agaric has no idea why. But Agaric can tell you how (with or without generous use of text emphasis, we're flexible).
This is Drupal: If there's not a module for that, there's a function for that. (Usually. If not you can write your own module with functions. But you don't need to do that to put the contact form wherever you'd like.)
You'll need to set your page to use the PHP input format, or create a "custom content" inside your panel, also set to use as its input format:
PHP code
* You may post PHP code. You should include <?php ?> tags.
With that little detail attended to, getting the form to show up where and how you want it is as simple
Resolution
<?php
print contact_site_page();
?>
Comments
Updated for Drupal 6 via James Shields - thanks James!
"Contact Form in Block"
Note that the more Drupal way in Drupal 6 to include a module's include file is with module_load_include(), so the code would become:
<?php
module_load_include('inc', 'contact', 'contact.pages');
print contact_site_page();
?>
Great article
Thanks for this, I hadn't seen this method used before. It looks like this will output the form, but when submitted, I don't receive the mail from the form to the address I specified and there is no 8user feedback given (whether the form was submitted properly), instead I get referred to the home page with no idea if all went as planned.
Any ideas on this?
Thanks
Very helpful!
Post new comment