Created
December 3, 2014 15:41
-
-
Save msankhala/496c203bc37ae06348bb to your computer and use it in GitHub Desktop.
Attach a site-wide contact form to a block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Open template.php in your theme folder and add the following code. Replace [THEME NAME] with the name of your theme. Replace the value of $module and $delta with the actual string values. | |
//Hint: To locate these values go to admin/structure/block and click on the "configure" link next to the block you want to print. The strings will be shown in the URL as such: admin/structure/block/manage/[module]/[delta]/configure. | |
/** | |
* Implements preprocess_block(). | |
*/ | |
function mytheme_preprocess_block(&$vars) { | |
// Preprocess the Contact form block. | |
$module = 'block'; | |
$delta = 3; | |
if ($vars['block']->module == $module && $vars['block']->delta == $delta) { | |
module_load_include('inc', 'contact', 'contact.pages'); | |
$contact_form = drupal_get_form('contact_site_form'); | |
// Manually prepare status messages. | |
$contact_form['#prefix'] = theme('status_messages'); | |
$vars['content'] = render($contact_form); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment