I have a module that works fine but I cannot seem to get node_view hook to work - seems to never be called. As a test, I tried adding this to the dennis.module in sites/all/modules/dennis, but nothing happens (Drupal 7).

function dennis_node_view($node, $view_mode, $langcode) {

  echo "AAAAAAAAAA";

  $node->content['body'] = array(
    '#markup' => "bonjour!"


Ultimately I need to find keywords in the content and replace with other text. So easy in WordPress and Joomla but after days of trying I have got nowhere with Drupal. Please help!

2 Answers 2


you can do this by jQuery also :

$('body').html($('body').html().replace('Original Text','New Text'));
  • Thanks for your reply, but I need to do this server-side.
    – Dennis
    Apr 30, 2013 at 0:21

I can't help with the code, but could you use the String Overrides module for this?


  • Easily replace anything that's passed through t()
  • Locale support, allowing you to override strings in any language
  • Ability to import/export *.po files, for easy migration from the Locale module
  • Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
  • Thanks for your reply, but I need to do this within my own module. It's part of how my module should work, not a one-off thing. I dont want to change the articles' text itself as stored in the database, just modify it on display.
    – Dennis
    Apr 27, 2013 at 19:32
  • Sadly, seems impossible to do this basic thing in Drupal so looks like I'll have to drop Drupal from supported CMSs.
    – Dennis
    Apr 30, 2013 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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