1

I want to use hook_form_alter in my Omega subtheme. I'm trying to put the function in the correct place but I'm getting no results after clearing caches and refreshing.

Here's the code:

<?php function rescue_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
  dsm($form_id);        // HTML5 placeholder attribute
    $form['search_block_form']['#attributes']['placeholder'] = t('enter search terms');
  }
}

I don't know whether to include a closing ?> or not. I've tried it both ways. I've tried saving it as preprocess-page.inc and process-html.inc but neither has given any result. Help?

  • Have you tried putting it straight into template.php? – Clive Jul 17 '12 at 18:32
  • No, because there's a README in there that says not to do that, and instead to put it in a process or preprocess include. – beth Jul 17 '12 at 18:33
  • Update: tried it for debugging purposes. It works that way. I'd still like to figure out the right way to do this. – beth Jul 17 '12 at 18:35
3

The preprocess.inc and process.inc files are an Alpha/Omega way of organizing template_preprocess and template_process functions. Basically, if your template.php would have a mytheme_preprocess_node, you would put it in preprocess-node.inc and name the function mytheme_alpha_preprocess_node. When you clear cache, and Drupal rebuilds the registry, the Alpha hooks will scan all of these files and wire everything up.

This doesn't mean that everything else that you put in template.php goes in these includes. Your custom theme functions and alters should still stay in template.php.

This can help keep the size of template.php managable, but I always still end up with large files because typically needs lots of theme and alter functions for the projects I work on.

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.