Custom drupal theme.... creating my own regions and the difficulty I am having with it!

Events happening in the community are now at Drupal community events on www.drupal.org.
jnicola's picture

Hey guys,

I posted earlier but had no response. I'm really at a dead end for how the heck I place custom regions in my own theme.

All the documentation makes it appear extremely easy, which is wigging me out. I've not only read a multitude of documentaiton, I've grabbed other themes with multiple custom regions, and tried to mimick their code and not had much for luck. I must be seriously missing something basic though.

Will one of you please help me out? Dinner and beer is completely on me, and hell maybe I can trade for automotive work, audio recording, electrical work, snowboard gear, snowboard lessons, discounts on snowboard gear (I ride for a shop)... hell... what's mine is yours to anyone who helps me!

Comments

Post requirements/code

nato's picture

If you can post a better explanation of what you want to do and/or a code example, people will have more to go on.

Your earlier post made it sound like you wanted to make custom blocks, which don't require custom regions. You can make a "custom" block with anything in it and place it in an existing region directly from admin/build/block/add.

Custom Regions

toddtomlinson's picture

Hi jnicola,

Quick question -- have you updated your template.php file to include the new regions that you set in your template.tpl.php? That is the first place to look. If you have and that still doesn't work -- shoot your template.php and your template.tpl.php file over to me via email and I'll add the mark-up and provide comments.

Todd Tomlinson
todd.tomlinson@ahaconsulting.com

See... there is no

jnicola's picture

See... there is no template.php file nor a template.tpl.php file. I tried creating one, and that was to no avail

I was able to get ahold of Steve though and we're meeting tomorrow. Hopefully he can help me out! The documentation concerning what to do in this situation is rather lackluster, but then again... I find drupal 5's documentation lacking as a whole.

Jesse Nicola -- Shredical six different ways to Sunday! -- My Portfolio

Are you using Drupal 5 or 6,

agrathea's picture

Are you using Drupal 5 or 6, jnicola?

If you're using 5, you have to add your region to the regions listed in the template.php file for your theme. Then you also add the code that creates that region in your page.tpl file.

In the template.php you'll see something like:

function themename_regions() {
return array(
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content_top' => t('content top'),
'content_bottom' => t('content bottom'),
'header' => t('header'),
'footer' => t('footer')
);
}

You just add one of your own to the list. Then, in the page.tpl there are various outputs for the different regions that you can copy for your own use:

<?php
print $sidebar_left;
?>

Or you can make it conditional... IF the theme detects the use of one of those regions, then and only then will it display:

<?php
if ($sidebar_left):
?>

<?php
print $sidebar_left;
?>

<?php
endif;
?>

If you are using 6 the process similar: you add the region to your .info file for the theme instead of the template.php:

regions[left] = left sidebar
regions[right] = right sidebar
regions[navbar] = navigation bar
regions[content_top] = content top
regions[content_bottom] = content bottom
regions[header] = header
regions[footer] = footer
regions[closure_region] = closure

...then add the region to the page.tpl file. In 6 you will have to refresh your cache to see the changes (details here: http://drupal.org/node/173880#theme-registry).

And the last step is to make sure you have elements outputting to that area. Once you've created a region and refreshed your cache, then you should see the new region available for blocks on the block settings screen.

Feel free to ping me directly if that doesn't help, and we can hook up over chat to talk in more detail.

Theresa

Drupal 5 See... I get all

jnicola's picture

Drupal 5

See... I get all that, it's quite easy!

The problem is I am not seeing any .theme file. I'm coding it all properly, and it doesn't work. So I tried adding the .theme file, and that didn't work either.

I actually was able to get ahold of Steve Edwards again. We're meeting over lunch tomorrow and he'll help me out a bunch hopefully. The situation is quite the pickle. If he doesn't have enough time to help me though I'd love to meetup and seek your help with all of this!

Thanks,
Jesse

Jesse Nicola -- Shredical six different ways to Sunday! -- My Portfolio

Nice explanation

nagella's picture

Hi Theresa,
You save my time. thanks a lot. Please let me know how to theme comment module for perticular content type.Thanks in advance..

Maheswar Reddy.Nagella

Portland (Oregon)

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: