Posted by jcicolani on June 25, 2010 at 12:50am
I am trying to build a custom theme for my much discussed photo workshop site using the 960 Grid base theme. I get it running all right, except one small problem. None of my blocks are displaying. In their place I get "1" or "0". The regions seem to work right, properly sized, etc., but the blocks aren't showing.
Here is my theme.info file:
name = Vandivier
description = 960 Grid Subtheme
version = VERSION
core = 6.x
base theme = ninesixty
engine = phptemplate
stylesheets[all][] = reset.css
stylesheets[all][] = 960.css
stylesheets[all][] = styles.css
regions[navigation] = Navigation
regions[user-box] = User Box
regions[front-slideshow] = Front Slideshow
regions[front-featured] = Front Featured
regions[front-left] = Front Left
regions[front-right] = Front Right
regions[footer-left] = Footer Left
regions[footer-middle] = Footer Middle
regions[footer-right] = Footer Right
regions[footer-bottom] = Footer Bottom
features[] = search
features[] = favicon
features[] = primary_links
And this is the page-front.tpl.php:
<?php
// $Id: page.tpl.php,v 1.1.2.1 2009/02/24 15:34:45 dvessel Exp $
?>
<!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" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
<head>
<title><?php print $head_title; ?></title>
<?php print $head; ?>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body class="<?php print $body_classes; ?> show-grid">
<div id="page" class="container-12 clear-block">
<div id="site-header" class="clear-block">
<?php if ($main_menu_links || $secondary_menu_links): ?>
<div id="site-menu" class="grid-12">
<?php print $main_menu_links; ?>
<?php print $secondary_menu_links; ?>
</div> <!-- /site-menu -->
<?php endif; ?>
<div id="header" class="grid-12 clear-block">
<div id="site-logo" class="<?php print ns('grid-11', $user-box, 4); ?> prefix-1 alpha <?php if(!$user-box): print 'omega'; endif; ?>"></div>
<?php if($user-box): ?>
<div id="user-box" class="grid-4 omega">
<?php print $user-box; ?>
</div> <!-- /user -->
<?php endif; ?>
</div> <!-- /header -->
</div> <!-- /site-header -->
<div id="main" class="column <?php print ns('grid-12', $left-sidebar, 2, $right-sidebar, 2); ?>">
<?php if ($title): ?>
<h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
<?php if ($tabs): ?>
<div class="tabs"><?php print $tabs; ?></div>
<?php endif; ?>
<?php print $messages; ?>
<?php print $help; ?>
<div id="front-slideshow" class="grid-8 alpha">
<?php print $front-slideshow; ?>
</div> <!-- /front-slideshow -->
<div id="front-featured" class="grid-4 omega">
<?php print $front-featured; ?>
</div> <!-- /front-featured -->
<div id="front-left" class="grid-6 alpha">
<?php print $front-left; ?>
</div> <!-- /front-left -->
<div id="front-right" class="grid-6 omega">
<?php print $front-right; ?>
</div> <!-- /front-right -->
<?php print $feed_icons; ?>
</div> <!-- /main -->
<?php if ($left-sidebar): ?>
<div id="left-sidebar" class="column sidebar region grid-2">
<?php print $left-sidebar; ?>
</div> <!-- /left-sidebar -->
<?php endif; ?>
<?php if ($right-sidebar): ?>
<div id="right-sidebar" class="column sidebar region grid-2">
<?php print $right-sidebar; ?>
</div> <!-- /right-sidebar -->
<?php endif; ?>
<div id="footer" class="grid-12 clear-block">
<?php if ($footer-left): ?>
<div id="footer-left" class="<?php print ns('grid-12', $footer-middle, 4, $footer-right, 4); ?>">
<?php print $footer-left; ?>
</div> <!-- /footer-left -->
<?php endif; ?>
<?php if ($footer-middle): ?>
<div id="footer-middle" class="<?php print ns('grid-8', $footer-right, 4) . ' ' . ns('prefix-4', $footer-left, 4); ?>">
<?php print $footer-middle; ?>
</div> <!-- /footer-middle -->
<?php endif; ?>
<?php if ($footer-right): ?>
<div id="footer-right" class="grid-4 <?php print ns('prefix-8', $footer-middle, 4, $footer-left, 4); ?>">
<?php print $footer-right; ?>
</div> <!-- /footer-right -->
<?php endif; ?>
<?php if ($footer-bottom): ?>
<div id="footer-bottom" class="grid-12 alpha omega">
<?php print $footer-bottom; ?>
</div> <!-- /footer-bottom -->
<?php endif; ?>
<?php if ($footer_message): ?>
<div id="footer-message" class="grid-12 alpha omega">
<?php print $footer_message; ?>
</div> <!-- /footer-message -->
<?php endif; ?>
</div> <!-- /footer -->
</div> <!-- /page -->
<?php print $closure; ?>
</body>
</html>
Thanks.
Comments
Were you able to figure this
Were you able to figure this out?
Not Yet
No... It's been put on the back burner until I get the actual functionality working right and the site up and taking orders. Unless you've got some insight? In the mean time, I'm putting in Panels.
Jeff Cicolani
@jcicolani
http://www.cicolanistudios.com
change dashes to underscores
I think if you replace the dashes with underscores in both the info and template file, your blocks will appear.
variable name string math ;}
Unfortunately I just found this out the hard way as well.
Yet another issue with php in general, but if you have a variable named region-first that you render like so:
print $region-first;
php thinks that both 'region' and 'first' are variables for whatever reason (even though first doesn't have a $ in front) and the 1 or 0 that you see are the output of math that php does instead of actually handling the variable.
Simply call your regions region_first instead and php doesn't think that it needs to do math (no need to confuse the poor thing).
Not sure why this doesn't cause errors without registerglobals disabled, but apparently it doesn't. This kind of behavior makes php very frustrating to work with, but oh well ;}
not a PHP problem
Most languages (c#, javascript, php that I know of) don't allow dashes in variable names.
You can use
print ${region-first};
to force php to recognize the entire string as the variable name, or use underscores.Also recall that constants in PHP don't use the $ prefix as in
<?php
define('FOO', 'bar');
echo FOO;
?>
If you were to turn on notices
error_reporting(E_ALL);
, you would see that php throws aNotice: Use of undefined constant first - assumed 'first' in FILE on line LINE
either or
either way, that's what the problem is ;P
was just frustrated that it took me that long to figured out why my theme was doing the same thing as the OP ;}