I'm very new to Drupal (coming from Wordpress), and I'm trying to set up this Google Ad manager module (http://drupal.org/project/google_admanager) to work.

I just don't understand this part:

Add the following code in template.php file or adjust _phptemplate_variables($hook, $vars) if it's already in

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

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

    return $vars;
  }
  return array();
}
?>

Can you help?

Comments

phdhiren’s picture

that means that you need to edit your template.php in theme directory (suppose you're using garland theme then it would be at themes/garland )

You'll found template.php in that.. If it is not there in your theme you can create one.

You need to add above code in your template.php file, that's it.
In case _phptemplate_variables function already there then you need to add this code inside that function.

TooFatToFish’s picture

Hey, thanks for the reply.

This is my template.php file:

<?php

drupal_add_css(path_to_theme().'/additional.css','theme');

function bluemarine_regions() {
  return array(
	'contenttop' => t('Content Top'),
	'sidebarright' => t('Right-hand Sidebar'),
  );
}
/**
 * views template to output a view.
 * This code was generated by the views theming wizard
 * Date: March 14, 2009 - 6:06pm
 * View: top_bar
 *
 * This function goes in your template.php file
 */
function phptemplate_views_view_list_top_bar($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
	$items .= node_view($node);
  }
  if ($items) {
    return $items;
  }
}

/**
* Catch the theme_user_profile function, and redirect through the template api
*/
function phptemplate_user_profile($account, $fields = array()) {
  // Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
  return _phptemplate_callback('user_profile', array('account' => $account, 'fields' => $fields));
  }

function bluemarine_comment_post_forbidden($nid) {
  global $user;
  static $authenticated_post_comments;

  if (!$user->uid) {
    if (!isset($authenticated_post_comments)) {
      // We only output any link if we are certain, that users get permission
      // to post comments by logging in. We also locally cache this information.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
    }

    if ($authenticated_post_comments) {
      // We cannot use drupal_get_destination() because these links
      // sometimes appear on /node and taxonomy listing pages.
      if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
        $destination = 'destination='. drupal_urlencode("comment/reply/$nid#comment-form");
      }
      else {
        $destination = 'destination='. drupal_urlencode("node/$nid#comment-form");
      }

      if (variable_get('user_register', 1)) {
        // Users can register themselves.
        return t('<center>There are comments! <a href="@login"><strong>Sign in</strong></a> or <a href="@register"><strong>sign up</strong></a> to check them out!</center>', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
      }
      else {
        // Only admins can add new users, no public registration.
        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
      }
    }
  }
}




?>

Where would I put that code in here?

TooFatToFish’s picture

Help please

danielb’s picture

just at the bottom

TooFatToFish’s picture

Thanks daniel. So put it after the ?> line?

chrism2671’s picture

archimax’s picture

Please explain what goes into the Ad slots: (Enter one Ad Slot name per line.) Is this free-text, like the name or ID# on Google's Manage Ads webpage, or is it something specifically related to my AdSense account and the ads I want displayed in this slot?

mathbouq’s picture

In your Google AdManager account, you have created the ad slosts you wished to fill on your website.

The names of these ad slots must be entered in the "Ad slots" field of the module in Drupal (one per line).
Once it's done and saved, you have one block per slot on your block management page, which you can move to any region of your pages.

archimax’s picture

AdSense provides a block of javascript unit code for each AdSense unit. Is this code needed? If so, where should this code be entered in Drupal?

mathbouq’s picture

You don't need to put the JS code from Google AdManager in your code: this code is automatically generated by the module once it is activated and you have some ad slots on your pages.