Hi folks,

I'm trying to serve a specific page template for all nodes that are forum posts.

As of right now, I've been twiddling in template.php to do similar work (serve different templates based on url arg()).
Here's the function I'm using. Note that I've bveen trying to grab the node type (if (arg(0) == 'node' && is_numeric(arg(1))) and then trying to load a page template based on that: elseif ($node->type == 'forum') {

I thought this was the proper way to do this, yet now I'm getting some mySQL errors:

warning: Invalid argument supplied for foreach() in /netops/www/drupal-4.6/modules/node.module on line 358.

warning: implode() [function.implode]: Bad arguments. in /netops/www/drupal-4.6/modules/node.module on line 363.

user error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
query: SELECT n.*, u.uid, u.name, u.picture, u.data FROM *****.node n  INNER JOIN *****.node_access na ON na.nid = n.nid INNER JOIN newmbc.users u ON u.uid = n.uid WHERE  (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','simple_access0')) AND   in /*****/www/drupal-4.6/includes/database.mysql.inc on line 66.

Anyone have an idea what I'm doing wrong here? Thanks in advance!

Here's my function from template.php:

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) {
    case 'page':
      global $user;
	  if (arg(0) == 'node' && is_numeric(arg(1))) {
	     $node = node_load(arg(1));
          }
      $vars['user'] = $user;
      if (arg(0) == 'admin' && arg(1) != 'node') {
        $vars['template_file'] = 'page-admin';
      }
	  elseif (arg(0) == 'node' && (arg(1) == '189' ||  arg(1) == '60' ||  arg(1) == '68' || arg(1) == '69' || arg(1) == '71' ||  arg(1) == '73' || arg(1) == '75' || arg(1) == '118')) {
        $vars['template_file'] = 'page-twocol';
      }
      elseif (arg(0) == 'node' && (arg(1) == '5' || arg(1) == '6' || arg(1) == '7' || arg(1) == '9' || arg(1) == '10' || arg(1) == '11' || arg(1) == 'feedback')) {
        $vars['template_file'] = 'page-onecol';
      }
      elseif (arg(0) == 'store' && arg(1) == 'history') {
        $vars['template_file'] = 'page-onecol';
      }
	  elseif (arg(0) == 'user' || arg(0) == 'forum' || arg(0) == 'tracker') {
        $vars['template_file'] = 'page-twocol';
      }
	  elseif (arg(0) == 'views' && (arg(1) == 'view-posts' || arg(1) == 'view-my-posts')) {
        $vars['template_file'] = 'page-twocol';
      }
	  elseif ($node->type == 'forum') {
        $vars['template_file'] = 'page-twocol';
           }
      break;
  }
  
  return $vars;
}