I'm have look through the code but I can't seems to find the right file and location to put the _phptemplate_variables call.

Can you show me an example on antique_modern theme or bluemarine them.

Thanks.
Ying

Comments

SemperFideles’s picture

Bump. I'm using a PHP template that doesn't have a template.php file.

alex ua’s picture

If you're using Zen, you put it before this call:
"$vars['body_classes'] = implode(' ', $body_classes);"

Or at least make sure that it's under this:
------
switch ($hook) {
case 'page':"
------

...and before the break that ends the call to the hook.

alex ua’s picture

...and as far as I can tell, this only works with PHPtemplate based themes. Bluemarine claims to be phptemplate, so just add a template.php file (beginning with <?php ) and add in the code provided. Not sure if it will work, but otherwise you should probably switch to a theme that is still actively supported.

backslash’s picture

Same here! I using a custom made php template without a template.php and cannot get it working.

I don't know actually what to put in my page.tpl.php and ofcource where exactly i put things in my page.tpl.php.

promes’s picture

I use the Pushbutton theme, a template based theme by default. Putting the code in a template.php file results in a page that reads: "Navigatie overslaan", Dutch for "skip navigation".
Has this code been tested with original Drupal themes?

After I remove template.php, I see 2 Drupal warnings:
* warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/html/themes/engines/phptemplate/phptemplate.engine on line 63.
* warning: extract() [function.extract]: First argument should be an array in /var/www/html/themes/engines/phptemplate/phptemplate.engine on line 391.

Contains the code an error?

davidwhthomas’s picture

If you don't have a template.php file in your theme folder.

Create a file called template.php in your theme folder

Put the phptemplate_variables function into that.

done! :-)

DT

wintervanilla’s picture

I'm using my own theme built up from the 'foundation' theme. It has a template.php file that looks like this:

<?php
/* $Id: template.php,v 1.1 2006/06/28 18:31:05 rkerr Exp $ */

function mesa_regions() {
  return array(
       'header' => t('header'),
       'toptabs' => t('top tabs'),
       'breadcrumbs' => t('bread crumbs'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'contenttop' => t('content top'),
       'content' => t('content'),
       'footer' => t('footer'),
       'bottomleft' => t('bottom left'),
       'bottomright' => t('bottom right')
  );
}
?>

Upon updating template.php it looks like this:

<?php

/* $Id: template.php,v 1.1 2006/06/28 18:31:05 rkerr Exp $ */

function mesa_regions() {
  return array(
       'header' => t('header'),
       'toptabs' => t('top tabs'),
       'breadcrumbs' => t('bread crumbs'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'contenttop' => t('content top'),
       'content' => t('content'),
       'footer' => t('footer'),
       'bottomleft' => t('bottom left'),
       'bottomright' => t('bottom right')
  );
}

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) { // what function is active?
    case 'page': // page is where menu comes into play
      // set the primary links
      $vars['primary_links'] = menutrails_primary_links(1);
      // you may want to also override secondary_links
      $vars['secondary_links'] = menutrails_primary_links(2);
      break;
}

?>

Am I doing it right? Because when I do this, it breaks my entire page. I get the following error:Parse error: syntax error, unexpected $end in /home/mesaprog/public_html/drupal/sites/all/themes/mesa/template.php on line 30

Thanks,
A

davidwhthomas’s picture

You're missing the closing bracket '}' for the switch statement

it should be:

<?php

/* $Id: template.php,v 1.1 2006/06/28 18:31:05 rkerr Exp $ */

function mesa_regions() {
  return array(
       'header' => t('header'),
       'toptabs' => t('top tabs'),
       'breadcrumbs' => t('bread crumbs'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'contenttop' => t('content top'),
       'content' => t('content'),
       'footer' => t('footer'),
       'bottomleft' => t('bottom left'),
       'bottomright' => t('bottom right')
  );
}

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) { // what function is active?
    case 'page': // page is where menu comes into play
      if (module_exists('menutrails')) { //add this check to prevent WSOD if mod is disabled
        // set the primary links
        $vars['primary_links'] = menutrails_primary_links(1);
        // you may want to also override secondary_links
        $vars['secondary_links'] = menutrails_primary_links(2);
      }
      break;
  } //add this bracket
}
wintervanilla’s picture

Hmm... thanks for the tip. That change did fix the error, however my entire page is broken (completely blank) when I have this function in my template.php file. Any idea what might be causing this? Is there a way around it?

davidwhthomas’s picture

Check your php error log for more debug info.

Or, see this page for WSOD (white screen of death) troubleshooting:

http://drupal.org/node/158043

DT

P.S I just noticed the function module_exists is for Drupal 5 + only. If you're using 4.x, take out the if(module_exists(... part

i.e:

<?php

/* $Id: template.php,v 1.1 2006/06/28 18:31:05 rkerr Exp $ */

function mesa_regions() {
  return array(
       'header' => t('header'),
       'toptabs' => t('top tabs'),
       'breadcrumbs' => t('bread crumbs'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'contenttop' => t('content top'),
       'content' => t('content'),
       'footer' => t('footer'),
       'bottomleft' => t('bottom left'),
       'bottomright' => t('bottom right')
  );
}

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) { // what function is active?
    case 'page': // page is where menu comes into play
        // set the primary links
        $vars['primary_links'] = menutrails_primary_links(1);
        // you may want to also override secondary_links
        $vars['secondary_links'] = menutrails_primary_links(2);
      break;
  } //add this bracket
}
opfs’s picture

wintervanilla: I don't know if you ever got the WSOD (white screen of death) sorted, but I just recently had the same problem with this module in D5. The code is missing a 'return $vars;' line at the end of the _phptemplate_variables function, which was the cause of the WSOD in my case:

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) { // what function is active?
    case 'page': // page is where menu comes into play
      if (module_exists('menutrails')) {
        // set the primary links
        $vars['primary_links'] = menutrails_primary_links(1);
        // you may want to also override secondary_links
        $vars['secondary_links'] = menutrails_primary_links(2);
      }
      break;
  }
  return $vars; // Add this line to fix WSOD
}
sun’s picture

Status: Active » Closed (won't fix)

Sorry, Menu Trails for Drupal 5 is not actively developed/maintained anymore. Only issues containing patches may still be considered. Feel free to re-open this issue if you want to provide a patch.