In the installation instructions in both the readme.txt AND on the Drupal project page it should be clearly stated that 2 functions have to be added/modified in template.php:
phptemplate_preprocess_page and _phptemplate_variables.

As of now, only phptemplate_preprocess_page is mentioned in readme.txt, while the project page only says to add _phptemplate_variables.

This causes a lot of confusion when installing this otherwise useful module.

Comments

toemaz’s picture

Thanks for reporting this issue. Since I have my hands full on several projects, could you perhaps provide me the instructions for configuring this module for D6? I'm actually only using this module on a D5 installation. Thanks!

duncan.moo’s picture

I was about to give up on this module when I saw this thread, but the documentation should be more clear. To get this working on D6 I did the following:
A. Insert the following into template.php

function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

    if (module_exists('google_admanager')) {
      $vars['scripts'] .= google_admanager_add_js();
    }

    return $vars;
  }
  return array();
}

B. Insert the following into template.php Into the function phptemplate_preprocess_page(&$vars)

  // Insert Google Ad Manager scripts into header
  if (module_exists('google_admanager')) {
  $vars['scripts'] .= google_admanager_add_js();
  }

That got it workig for me.

highvoltage’s picture

Hmm, there's no mention of "function phptemplate_preprocess_page(&$vars)" anywhere... not on the front page and not on the readme? Where did this come from? Is it still relevant or out of date?

I've added this to my template.php:

/**
* Google ad manager
*/
function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

    if (module_exists('google_admanager')) {
      $vars['scripts'] .= google_admanager_add_js();
    }

    return $vars;
  }
  return array();
}

function phptemplate_preprocess_page(&$vars) {
  // Insert Google Ad Manager scripts into header
  if (module_exists('google_admanager')) {
  $vars['scripts'] .= google_admanager_add_js();
  }
}

Is this correct?

dankohn’s picture

Category: feature » bug
Priority: Normal » Critical

Please note that this is a bug, not a feature request. The directions (including what is in the Readme.txt and what is on the project page) need to be updated to show the instructions from #2. Thanks.

toemaz’s picture

Status: Active » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.