Skip to main content

Allowing unfiltered content on the Drupal contact page

An article from ComputerMinds - Building with Drupal in the UK since 2005
16th Dec 2007

Mike Dixon

Senior Mind
Mike Dixon
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

The contact page exposed by the Drupal contact module is great, it allows you to put together a contact form quickly and easily. But there is one small(ish) problem, the header text for the form is being filtered - which prevents you from using certain tags (for example embed). We found this problem when trying to embed a youtube movie onto the drupal contact form.

The solution is a little bit of themeing - put the following in your template.php file, you will have to be a bit carefull as your now not filtering your output - so you HAVE to be able to trust the person editing the contact form details.

 


/**
* Customise the contact page
*/
function theme_contact_mail_page($form){
	$output = variable_get('contact_form_information', t('You can leave a message using the contact form below.'));  
	//NOTE this is not being filtered so we can include HTML in the contact form
	unset($form['contact_information']);
	$output .= drupal_render($form);
	return $output;
}

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.