Page template variables in 6.x ($left and $right)
NonProfit - August 2, 2008 - 14:52
Hi, I'm creating a custom theme in Drupal 6 from scratch and struggling with my page.tpl.php template files.
This
<div id="sidebar-left">
<?php print $left ?>
</div> <!-- /sidebar-left --> and
<div id="scroller">
<?php print $right ?>
</div><!-- /scroller -->don't populate the divs with blocks set to display in the left and right sidebars (set via /admin/build/block).
I'm using Garland as my admin theme and it populates the sidebars correctly. I'm 99% certain my problem is naming the variables above, but just can't find the solution. No regions have been defined in the .info file but I don't think that's the issue, as $content displays just fine...
Thanks!
-NP

The two default left and
The two default left and right variables are $sidebar_left and $sidebar_right.
___________________
Preston So
Web/Print Designer
Monarch Digital, Colorado Springs
My near-dead non-Drupal site
Was that changed in 6?
Hey prestonso , thanks for your reply.
I thought that I had read this was changed in 6. Anyway, I replaced it with:
<div id="sidebar-left"><?php print $sidebar_left ?>
</div> <!-- /sidebar-left -->
and
<div id="scroller"><?php print $sidebar_right ?>
</div><!-- /scroller -->
Output remains unchanged. An additional note...the other attributes of the div are being applied (height, width, background image, etc.) so it's not that the div is not being rendered.
Thanks!
-NP
Regions
Do you have other regions defined? If so, only those regions are defined.
Post your .info file? or relevant part of template.php?
___________________
It’s in the detaιls…
demonstration portfolio
Define them in your info
Define them in your info file, that should clear up the problem.
regions[left] = Sidebar left
regions[right] = Sidebar right
Be sure to clear the theme registry (go to performance and clear cache data) as the .info file gets cached.
6.3 theming woes
zeta ζ & jmburnz,
Thanks for your replies:
I have some kooky theming issues. First, the code:
An .info file:
; $Id: july2.info,v 1.5 2007/07/01 23:27:32 goba Exp $
name = july2
description = July2 theme.
version = VERSION
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
stylesheets[print][] = print.css
; Information added by drupal.org packaging script on 2008-04-09
version = "6.3"
project = "drupal"
datestamp = "1207776008"
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
Garland's template.php:
<?php
// $Id: template.php,v 1.16 2007/10/11 09:51:29 goba Exp $
/**
* Sets the body-tag class attribute.
*
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
*/
function phptemplate_body_class($left, $right) {
if ($left != '' && $right != '') {
$class = 'sidebars';
}
else {
if ($left != '') {
$class = 'sidebar-left';
}
if ($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>';
}
}
/**
* Allow themable wrapping of all comments.
*/
function phptemplate_comment_wrapper($content, $node) {
if (!$content || $node->type == 'forum') {
return '<div id="comments">'. $content .'</div>';
}
else {
return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
}
}
/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
$vars['tabs2'] = menu_secondary_local_tasks();
// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
}
/**
* Returns the rendered local tasks. The default implementation renders
* them as tabs. Overridden to split the secondary tasks.
*
* @ingroup themeable
*/
function phptemplate_menu_local_tasks() {
return menu_primary_local_tasks();
}
function phptemplate_comment_submitted($comment) {
return t('!datetime — !username',
array(
'!username' => theme('username', $comment),
'!datetime' => format_date($comment->timestamp)
));
}
function phptemplate_node_submitted($node) {
return t('!datetime — !username',
array(
'!username' => theme('username', $node),
'!datetime' => format_date($node->created),
));
}
/**
* Generates IE CSS links for LTR and RTL languages.
*/
function phptemplate_get_ie_styles() {
global $language;
$iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
$iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
}
return $iecss;
}
And a custom page template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print $head_title ?></title>
<?php print $head ?>
<?php print $styles ?>
<?php print $scripts ?>
</head>
<body>
<div id="page">
<div id="sidebar-left"> <p>Sidebar-left</p>
<?php print $left ?>
</div> <!-- /sidebar-left -->
<div id="curve-left">
</div> <!-- /curve-left -->
<div id="scroller"><p>Sidebar-right</p>
<?php print $right ?>
</div><!-- /scroller -->
<div id="curve-right">
</div><!-- /curve-right -->
<div id="container">
<div id="header">
</div> <!-- /header -->
<div id="content">
<?php print $help ?>
<?php print $tabs ?>
<?php print $messages ?>
<?php print $content ?>
</div> <!-- /content -->
<div id="footer">
<?php print $footer_message ?>
<?php print $feed_icons ?>
</div> <!-- /footer -->
</div> <!-- /container -->
</div> <!-- /page -->
<p class="tiny">Created by link</p>
<?php print $closure ?>
</body>
</html>
Also included are three background images and a .css file. Regions were recently added to the .info file with no change in output.
The layout of the page is working fine. I included the page template's
<p>Sidebar-left</p> and <p>Sidebar-right</p>as a test and they appear properly. (So at the very least, the divs are named correctly.) Also, caches were cleared in./admin/settings/performance.Here is the weird part. Primary links display in the left sidebar. When $left is deleted from the page template the links are not rendered. However, I'm using Garland as my admin theme which displays the Primary links in the right sidebar (as they are set in /admin/build/block). Garland also properly displays additional blocks in the right sidebar which are omitted in my theme. Again, this happens with a clear cache and output will change as I toggle between admin and public pages. There are two issues here, a) I somehow exchanged $left and $right and b) the variables' output is changing based on the theme displayed. Also, the other sidebar (scroller) displays properly in Garland as nothing is rendered in my theme. KOOKY!
What could I possibly be doing wrong?
Thank you,
-NP
Are you sure your block
Are you sure your block settings for you custom theme are correct?
I'm a Bonehead!
jmburnz, you got it. Thanks. -NP