You are here

function adsense_injector_nodeapi in Content Injector (formerly AdSense Injector) 5

Same name and namespace in other branches
  1. 5.2 adsense_injector.module \adsense_injector_nodeapi()
  2. 6.3 adsense_injector.module \adsense_injector_nodeapi()
  3. 6 adsense_injector.module \adsense_injector_nodeapi()
  4. 6.2 adsense_injector.module \adsense_injector_nodeapi()

Implementation of hook_nodeapi. If rendering a full page, and the node type one of the configured types, inject configured adsense content using simple string concatenation. @todo: Evaluate efficiency of string concat vs. sprintf, other methods.

File

./adsense_injector.module, line 123

Code

function adsense_injector_nodeapi(&$node, $op, $teaser, $page) {

  // insert an ad into the body.
  if (module_exists('adsense') && _adsense_page_match() && variable_get(ADSENSE_INJECTOR_INSERT_AD_NODETYPE . $node->type, FALSE)) {
    if ($op == 'view') {
      $node->content['body']['#value'] = theme('adsense_injector_transform', $page, $teaser, $node);
    }
  }
}