Search

Drupal 7: Ensure HOOK_node_view is not called by search indexing

When using HOOK_node_view() you should take care because when the search (Search API especially) is indexing, this hook is also being called. You can not rely on a user displaying the node display currently. Here's a way to ensure this...

  1. function MYMODULE_node_view($node, $view_mode, $langcode) {
  2.   if ($view_mode != 'full' || arg(0) != 'node') {