So I have a content type "Real Estate." On the view for a "Real Estate" node, I want to have a contact block in the right side bar that has a feild for the node id of this specific "Real Estate" node.

An example of the feature I'm trying to make can be seen here

This problem has two parts which I'm not sure how to do. The first is that I don't know how to make a block for a contact form. I know drupal has a default Contact module but I'm not sure how to turn this into a block or even if that is the best way to go (maybe WebForms module can help?) Second is that I'm not sure how to pre-load the node id into the form. I'm sure that this would require a hook of some kind but seeing as I don't know how to make the contact form block, I don't know what hook to use.

Any help would be much appreciated. Thanks!

1 Answer 1


If you don't want to write custom theming and you want less coding, you need to create a custom page with 2 columns using panels module.

  1. Install the panels and ctools modules if you don't have.
  2. Enable Chaos tools, Page manager and Panels.
  3. Create a custom page at admin/structure/pages/add with the path "estate/%node" which will be a new mirror page of the existing path "node/%node".
  4. Assign Node: ID context to the argument %node.
  5. Choose two column layout.
  6. Add Existing node to the left column. To use a NID from the URL, use %1 in the title box.
  7. For the right column, add the contact form from Widgets.

To get node information in the contact form, you need to write a hook hook_form_FORM_ID_alter in your custom module using the argument NID. You can study custom moduling here. Here is the example code snippet.

 * Implementation of hook_form_alter().
 * @see http://api.drupal.org/api/function/hook_form_alter
function yourmodule_form_contact_mail_page_alter(&$form, &$form_state, $form_id) {

    if(arg(0) == 'estate' && is_numeric(arg(1)){
        $node = node_load(arg(1));


You can also see how can you customize the contact form here:

The drawback of this solution is you have to use the new path "estate/%node" to the node view page instead of using the default existing path "node/%node".
Any better answer is welcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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