Drupal 6: How to add a new region to a theme
I added a new region line to my .info file under /sites/all/themes/[theme] directory. However when I look at the Blocks page, the region is not visible, nor is it a selectable item from the dr开发者_开发百科opdown menus. I've cleared the cache as well. What am I missing?
If you have multiple themes enabled, make sure you are looking at the correct theme on the block configuration page.
For example, if you have custom_theme and garland enabled, there is a block configuration page for each.
Go to http://www.example.com/admin/build/block/list/custom_theme to see blocks for your custom_theme
Go to http://www.example.com/admin/build/block/list/garland to see blocks for the garland theme
etc... for all enabled themes
When you say you cleared the cache, are you actually referring to the Theme Registry? Or did you really clear the database cache? If you just cleared the theme registry, it won't reflect the changes to the theme's .info file. You can clear the cache by...
- Use the "clear all cached data" link or button located at "Administer > Site configuration > Performance".
- With the devel block enabled (comes with devel module), click the "Empty cache" link.
- Simply visit the theme select page at "Administer > Site building > Themes".
List from Drupal.org
It's also possible the browser itself is caching pages. You could clear your browser cache, as well as the Drupal cache, just to be absolutely sure.
If none of that works, could you post your region assignment from the .info file?
I'm presuming Drupal 6 here, but in your andytheme.info, did you add the region like this (look at the bottom line):
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[andyregion] = Andy Region
Remember that you have to add all the regions if you add any in your .info file--they won't be inherited from your base theme.
And, in your page.tpl.php, did you add the region variable to be printed somewhere? Something like this?
<div class="region andyregion"><?php print $andyregion ?></div>
Of course, it would be surrounded by whatever and other stuff you'd want. Then flush the cache and see if it's in the blocks.
Andy-
The following assumes you use Zen as the base template.
Open up
/sites/[yoursite]/themes/[yourtheme]/[yourtheme].info
file and scroll down to where there are loads ofregions[xxx] = yyy
The name in brackets is the machine name of the region. The text after the equals sign is a descriptive text used on the
admin/structure/blocks
page.Open up
/sites/[yoursite]/themes/[yourtheme]/templates/page.tpl.php
and adding<?php print render($page['MACHINE-NAME']); ?>
where you want the region to appear.
精彩评论