Hi guys!

I am going crazy trying to do something... I wonder if someone could help me out a bit.
I am using Drupal 6.1, with the official Contact Form module. I have the Contact Form page up and running, but I have to embed only the form (without the side menus) in another page (node) of the same website. In other words, I have to create a new page, write a few things on it, and embed below the contact form, using PHP.
I tried using drupal_get_form and drupal_execute, reading some suggestions here and there, but I get errors.
Can someone give me some advice? How should I use these two functions?
Thx!

Comments

zilla’s picture

instead of beating yourself up trying to cobble it together, check out webform module for d6: http://drupal.org/project/webform - it may save you some time and since it creates a node to house the form, you can simply set all blocks to 'not show on that specific page'

silvero’s picture

Thank you for the tip! I had to prepare some feedback polls, and that software was what I was looking for. If I am not able to embed the Contact Form, I will try making a new one using WebForm.
I feel that I am getting closer to solving the problem. I found this guide: http://drupal.org/node/236997
I tried inserting:

<?php
print drupal_get_form('contact_mail_page');
?>

in another website I have, that is running Drupal 5.x. It works great!
Unfortunately, In my website running Drupal 6.1 I get this error:

warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, 'contact_mail_page' was given in /web/htdocs/www.englishforitalians.com/home/drupal/includes/form.inc on line 358.

Does anyone know what changed from 5.x to 6.x that could give this error? I don't quite understand the output...

THX!!!!
=)

VM’s picture

all that changes between Drupal 5 and Drupal 6 can be found here for modules : http://drupal.org/node/114774

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

silvero’s picture

THX!!!
Reading your link, I found out that Include files in drupal 6 are now conditionally loaded as a performance enhancement..
Following the example, I tried:

<?php
  module_load_include('inc', 'node', 'node.pages');
  print drupal_get_form('contact_mail_page');
?>

but I still get the same error. Is there a way to load all the modules, to make sure nothing is missing?
Maybe it's because I am inserting this in the body of a page... or maybe I don't have my Drupal 6 configured for manual loading of modules...
Thx for all the help so far, guys, I appreciate it.

silvero’s picture

WOW!!!
I entered #Drupal on Freenode and asked for help. And here comes this boombatower guy that gives me the solution!!!

<?php
  require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';
  print drupal_get_form('contact_mail_page');
?>

THX again, everyone, for your help!
I will try to post the solution on this page: http://drupal.org/node/236997

zilla’s picture

could this be hacked to show on a user profile view such if user has enabled contact, the block appears?

daddydo’s picture

Hi,
Thank you for this solution. But submitting the form without filling in all required fields, the error messages jump to the page.
They should of course stay in the block itself. Better solution for me is to remove those messages completely as the box borders turn red which is enough for drawing the attention to the submitter. How can I achieve this (drupal 6.4).
Further I'm looking for a css file to know what names the fields have in order to style them.
Looking forward to your reply. Thanks.

Garry Egan’s picture

Absolutely perfect.

<?php
  require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';
  print drupal_get_form('contact_mail_page');
?>

That little 4-line blurb of code is SOO easy to insert. I can add a contact page at the end of a post at-will now. THANK YOU. I had previously had modules, etc. Ridiculous. BOOMBATOWER's solution is effective and simple. (you'd think there would just be a checkbox in /node/edit that said "Add Contact Form".

Hmm,

fildawg’s picture

This is a great solution! Thank you!

Is there a way to display a users contact form the same way?

GiorgosK’s picture

I just wrote a handbook page on embedding the contact form to a node

I would suggest this solution
if you don't need to tweak the contact form itself
and using a webform is an overkill

------
GiorgosK
Geoland Web development / web marketing

------
GiorgosK
Web Development