2

I'm using Drupal 7 and I wanted users to be able to contact me via email whilst I'm still working on the website. So my plan was to use 'create a contact form', as I don't want to expose my email address.

However whenever I try to add an input element in the maintenance mode message it is completely ignored in the output. I think that this is because the message uses the filtered HTML file as I do have other bits of HTML the message that are rendering just fine, but I can't see any option to change which filter is used.

Is there a way to change the filter to full HTML or is there a better a option?

0

If you are comfortable with Custom coding, you can try following route

On your theme template.php implement template_preprocess_maintenace(), this will help you introducing new variables to maintenance page tpl file, something like below

function yourtheme_name_preprocess_maintenance_page(&$vars) {
  if (function_exists('_your_form_builder_funtion')) {
    $vars['your_custom_form'] = drupal_render(drupal_get_form('_your_form_builder_function'));
  }
}

Now copy the maintenance-page.tpl.php in your custom theme templates folder and on the template file, you can use the variable like any other being already used. So somewhere on your maintenance-page.tpl.php add following

  <div class="contact-form">
    <?php print $your_custom_form; ?>
  </div>
  • 1
    As side note, it should be template_preprocess_maintenance_page() in Drupal 7. – kiamlaluno Sep 13 '15 at 17:32
  • Thank you very much for your answer! This looks like a great solution and it is just what I'm looking for. However I can't seem to be able to get the hook working - when I use themename_preprocess_maintenance_page the variable isn't available in the template but when I type template_proprocess_maintenance_page (litterally - do I replace template with something) I get a blank white page? – Andy Sep 13 '15 at 18:52
  • You need to replace themename with your theme name so for ex. if its bartik then your preprocess function will look like bartik_preprocess_maintenance_page() and then clear drupal caches to allow drupal to register the new preprocess suggestion. The reason you are gettting white page is because of the name of preprocess function which is already declared in drupal core, so you must be getting function redeclared error (api.drupal.org/api/drupal/includes%21theme.inc/function/…) – arpitr Sep 13 '15 at 19:09
  • 1
    Perfect, thank you for that clarification - it turns out that everything was right but I was outputting the variable in the wrong place iin the maintenance page template (my fault; sorry). Works a treat now - thanks for the fast solution. – Andy Sep 13 '15 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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