Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I want to add a small html within the body tag of the site. I believe I can use template preprocess for this. I don't want to touch the template files. I am doing this from a module.

share|improve this question
Is there a particular reason why you don't want to touch the page.tpl.php? If you mind about changing the original theme you can create a subtheme. – BetaRide Mar 25 '12 at 6:55

2 Answers

up vote 3 down vote accepted

You should add hook_node_view() into your module. See the given example on how to add HTML markup.

function mymodule_node_view($node, $view_mode, $langcode) {
  $node->content['my_additional_field'] = array(
    '#markup' => $additional_field, 
    '#weight' => 10, 
    '#theme' => 'mymodule_my_additional_field',
  );
}
share|improve this answer

You can use hook_preprocess_page() for that:

MODULENAME_preprocess_page(&$vars) {
  // …
}    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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