Hi,

your module helped me out for several pages with various themes, but now I cannot get it worked with theme Barlow. Template.php code is:

<?php
function barlow_regions() {
  return array(
    'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'before_content' => t('before content'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer')
    );
}

function  _phptemplate_variables($hook, $vars) {
  switch($hook) {
    case 'page': {
      drupal_add_css($vars['directory'] . '/layout.css', 'theme');
      drupal_add_css($vars['directory'] . '/typography.css', 'theme');
      $vars['styles'] = drupal_get_css();
    }
    case 'node':
      if (count($vars['node']->taxonomy)) {
        $vars['terms'] = t('Tags: !tags', array('!tags' => $vars['terms']));
      }
      if ($vars['submitted']) {
        $vars['author'] = t('By: !user', array('!user' => theme('username', $vars['node'])));
      }
      break;
  }

  return $vars;

    }

How can I modify it that it will work with this great module?

Thanks,
mauk

Comments

nicholasthompson’s picture

change _phptemplate_variables function to:


function  _phptemplate_variables($hook, $vars) {
  switch($hook) {
    case 'page': {
      drupal_add_css($vars['directory'] . '/layout.css', 'theme');
      drupal_add_css($vars['directory'] . '/typography.css', 'theme');
      $vars['styles'] = drupal_get_css();

      // Page Title goes here
      if (module_exists('page_title')) {
        $vars['head_title'] = page_title_page_get_title();
      }
    }
    case 'node':
      if (count($vars['node']->taxonomy)) {
        $vars['terms'] = t('Tags: !tags', array('!tags' => $vars['terms']));
      }
      if ($vars['submitted']) {
        $vars['author'] = t('By: !user', array('!user' => theme('username', $vars['node'])));
      }
      break;
  }

  return $vars;
}
nicholasthompson’s picture

Status: Active » Fixed
mauk’s picture

Hi,

thanks page_title now works, but get errors. I have changed template.php to:

<?php
function barlow_regions() {
  return array(
    'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'before_content' => t('before content'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer')
    );
}

function  _phptemplate_variables($hook, $vars) {
  switch($hook) {
    case 'page': {
      drupal_add_css($vars['directory'] . '/layout.css', 'theme');
      drupal_add_css($vars['directory'] . '/typography.css', 'theme');
      $vars['styles'] = drupal_get_css();

      // Page Title goes here
      if (module_exists('page_title')) {
        $vars['head_title'] = page_title_page_get_title();
      }
    }
    case 'node':
      if (count($vars['node']->taxonomy)) {
        $vars['terms'] = t('Tags: !tags', array('!tags' => $vars['terms']));
      }
      if ($vars['submitted']) {
        $vars['author'] = t('By: !user', array('!user' => theme('username', $vars['node'])));
      }
      break;
  }

  return $vars;
}

But now getting following error alert, if I try to log-in:

warning: Cannot modify header information - headers already sent by (output started at /srv/www/vhosts/domain.de/httpdocs/themes/berlin/template.php:1) in /srv/www/vhosts/adressen-aus-berlin.de/httpdocs/includes/session.inc on line 100. 
warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /srv/www/vhosts/domain.de/httpdocs/includes/session.inc on line 103. 

What is wrong?

Thanks for your very good support!

Mauk

mauk’s picture

Status: Fixed » Active
mauk’s picture

By the way, I am using Drupal 5.10

Kindest regards,
mauk

nicholasthompson’s picture

Title: Page_Title does not work with theme Barlow? » Page Title causing form submission errors: Cannot modify header information - headers already sent

what is you php error level? I believe drupal requires E_ALL ^ E_NOTICE. Its possible something is causes a notice error which is interrupting the redirection...

Its rather odd, I've never had that error! I'll take a look.

Just a thought: Do you have a blank line of whitespace at the top of template.php BEFORE the php opening marker?

mauk’s picture

Hi,

no, not any blank line nor whitespace.

Its possible something is causes a notice error which is interrupting the redirection... - Correct.

If I log-in I will be not re-directed to page, only "white" site appears without any content, etc. If I delete php-code for
page_title everything is fine.

I repeat complete php_template:

<?php
function barlow_regions() {
  return array(
    'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'before_content' => t('before content'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer')
    );
}

function  _phptemplate_variables($hook, $vars) {
  switch($hook) {
    case 'page': {
      drupal_add_css($vars['directory'] . '/layout.css', 'theme');
      drupal_add_css($vars['directory'] . '/typography.css', 'theme');
      $vars['styles'] = drupal_get_css();

      // Page Title goes here
      if (module_exists('page_title')) {
        $vars['head_title'] = page_title_page_get_title();
      }
    }
    case 'node':
      if (count($vars['node']->taxonomy)) {
        $vars['terms'] = t('Tags: !tags', array('!tags' => $vars['terms']));
      }
      if ($vars['submitted']) {
        $vars['author'] = t('By: !user', array('!user' => theme('username', $vars['node'])));
      }
      break;
  }

  return $vars;
}




/**
 * Sets the body-tag class attribute.
 *
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
 */
function phptemplate_body_class($sidebar_left, $sidebar_right) {
  if ($sidebar_left != '' && $sidebar_right != '') {
    $class = 'sidebars';
  }
  else {
    if ($sidebar_left != '') {
      $class = 'sidebar-left';
    }
    if ($sidebar_right != '') {
      $class = 'sidebar-right';
    }
  }

  if (isset($class)) {
    print ' class="'. $class .'"';
  }
}

/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *   An array containing the breadcrumb links.
 * @return a string containing the breadcrumb output.
 */
function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">'. implode(' → ', $breadcrumb) .'</div>';
  }
}

function phptemplate_username($object) {

  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 15) .'...';
    }
    else {
      $name = $object->name;
    }

    if (user_access('access user profiles')) {
      $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
    }
    else {
      $output = check_plain($name);
    }
  }
  else if ($object->name) {
    // Sometimes modules display content composed by people who are
    // not registered members of the site (e.g. mailing list or news
    // aggregator modules). This clause enables modules to display
    // the true author of the content.
    if ($object->homepage) {
      $output = l($object->name, $object->homepage, array('class' => 'anonymous', 'title' => t('not verified')));
    }
    else {
      $output = '<span class="anonymous" title="'. t('not verified') .'">'. check_plain($object->name) .'</span>';
    }
  }
  else {
    $output = variable_get('anonymous', t('Anonymous'));
  }

  return $output;
} 

/**
 * Theme an image node teaser
 */
function phptemplate_image_teaser($node) {
 return l(image_display($node, 'thumbnail'), 'node/'. $node->nid, array('class' => 'image'), NULL, NULL, TRUE, TRUE) . $node->teaser;
}

I noted that there is no closing PHP-tag but if I delete php-function of page_title it works fine, even without this closing tag. Any idea?

Thanks
Bernt

nicholasthompson’s picture

This is VERY odd!

I'll have to take a look through the code, but to me it sounds like something it outputting a white-space before the code.

template.php should NOT have a ?> at the end. Strange how PT2 is doing this...

mauk’s picture

Hi,

no white-space. Really strange. I never had any problems with your module. May be problem of Barlow?

Bernt

mauk’s picture

Hi,

I think the problem is the "double" template.php. One was included in my theme directory and one comes with your module. So I deleted module template.php and now it works.

Thanks for your support.

Bernt

nicholasthompson’s picture

Status: Active » Fixed

Thats incredibly odd... Thats NEVER been a problem with any other sites. I wonder what 'Barlow' does... I'll have to investigate that one day.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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