0

I am embedding the Drupal contact page in a node. I added the following code in template.php.

function sakura_preprocess_node(&$variables) {
  $node  = $variables['node'];
  if (!empty($node)) {
    $variables['template_files'][] = "node-" . $node->nid;
  }
}

Then, I created the node-24.tpl.php template file (for the node where I add the contact form).

require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';

//no need to maintain two version of node.tpl.php
include "node-page.tpl.php";

function local_contact_page() {
  $form = contact_mail_page();
  // override default values here if you want
  // next one will select a different category
  //$form['cid']['#default_value'] = 0;
  $form['submit']['#value'] = 'Отправить';
  unset($form['copy'], $form['subject']);
  dpm($form);
  return($form);
}

function local_contact_page_submit($form_id, $form_values) {
  return(contact_mail_page_submit($form_id, $form_values));
}

function local_contact_page_validate($form, $form_state) {
  return(contact_mail_page_validate($form, $form_state));
}

print drupal_get_form('local_contact_page');

drupal_set_message($form_id);

I also enabled the CAPTCHA module with the math method. On /contact it shows the CAPTCHA, but it doesn't show it on the contact form I embebbed in the node.

How can I make the CAPTCHA appear on the node page with the contact form?

1
  • You might be looking for hook_form_alter to alter the existing form. embedding form/PHP in a node with PHP Filter module is never a good idea.
    – AKS
    Commented Feb 13, 2013 at 12:33

1 Answer 1

1

Webform module is best for creating forms and still having options that come with regular nodes. It also integrates with captcha.

What is the reason you are embedding the form in the node like that?

2
  • Because i won't use that module for just a single form :( i want to integrate captcha in the core contact form. Commented Oct 21, 2012 at 19:09
  • Can you achieve the same functionality by using blocks and showing them only on the /contact page? Why do you want to embed the contact form in a node, instead of just using the /contact page? Commented Oct 21, 2012 at 19:12

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.