Adding new region to Garland Theme

p0732658 - April 10, 2007 - 01:53

Hi !

I would really like to add new region to the Garland Theme. I've tried the Zen Theme and it offer the block like those:

content-top
content-bottom

I know there are some documentation about doing this with the phptemplate engine, but the synthaxe doesn't seem to be the same. Does anyone did this in Garland?

Thank you

How to define custom regions

jwolf - April 10, 2007 - 08:52

Like I said, doesn't applies to the Garland theme...

p0732658 - April 10, 2007 - 13:55

Like I said, the documentation on Drupal Web site doesn't seem to applies to the Garland Theme because the syntaxe use in that them doesn't math the one use in the exemple provided in the documentation.

Seems to work for me

jwolf - April 10, 2007 - 22:14

Replace "mytheme" with garland (or the name of your theme).

template.php :

function garland_regions() {
  return array(
    'content_top' => t('content top'),
    'content_bottom' => t('content bottom')
  );
}

Place the region within page.tpl.php :

<?php print $content_top; ?>

Also, get rid of the hyphen (-) in your regions' names; use an underscore instead (_) = content_top

Perhaps you should read the documentation. It does "applies".

Thank you very much...

p0732658 - April 12, 2007 - 18:26

Thank you for your very clear explanation. I not a very got programmer, but this is very well explain...

I tried this, but my other regions don't show...

p0732658 - April 12, 2007 - 20:10

I tried adding the code to my template.php file into the Garland theme. The new content_top and content_bottom regions are shown, but node the originals regions. (sidebar left, sidebar_right, content, header and footer). Any ideas ?

To show all regions...

hsalazar - April 13, 2007 - 02:46

p0732658:

You need to consider this: when creating an overriding function in your own template.php file, you are replacing the original definitions, not adding to them. So you probably need something like:

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

Cheers.

That is exactly what I dit... and it Work!

p0732658 - April 13, 2007 - 15:16

Thank you for your replay. I figured this by myselft and it works. Anyway, thank you!

can't find function Garland_regions() in template.php (v5.1)??

dkdev - June 6, 2007 - 05:29

Never mind, I just realized that the default is defined elsewhere, but this allows an override.

Seems to be working.

You can also do something

gpk - June 13, 2007 - 12:39

You can also do something like this to add a region (this gets the regions already defined in the theme engine (see phptemplate.engine) and adds a custom region at the end):

function garland_regions() {
  $regions = phptemplate_regions();
  $regions['content_bottom'] = t('content bottom');
  return $regions;
}

It works in D5. How about

faqing - February 27, 2008 - 00:45

It works in D5. How about D6? Any hints?

Thanks pgk. In D6, it is

faqing - February 27, 2008 - 07:45

Thanks pgk.

In D6, it is easier. Just add the following to the garland.info

regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[top] = Top
regions[bottom] = Bottom

I just add Top and Bottom regions, but I need to add the above. Otherwise, the default regions (left, right, content, header, footer) will disappear.

Hyphens in themes

jiangxijay - October 5, 2007 - 18:45

You also have to get rid of any hyphens that may be in theme names.

Works great!

horizontal Banner region in garland's blue band

rolandk - February 15, 2008 - 22:06

Can anyone tell me how to insert a horizontal Banner region in garland's blue band.

This is not the header region.

It should appear in Garland's blue band across the top.

Thanks

anyone ?

rolandk - February 16, 2008 - 03:12

anyone ?

subscribe

vkr11 - February 16, 2008 - 17:55

subscribe

Why don't you check this

faqing - February 18, 2008 - 14:31

Why don't you check this modified garland theme?
http://thanhsiang.org/faqing/node/59

The default header region is

gpk - February 18, 2008 - 14:06

The default header region is the thin pale blue strip across the top. Do you mean the darker blue region where the site title and primary and secondary links appear, or the pale blue stip just below this (and just above page content) where the breadcrumb usually appears?

gpk
----
www.alexoria.co.uk

Yes, I mean the darker blue

rolandk - February 18, 2008 - 14:28

Yes, I mean the darker blue region where the site title and primary and secondary links appear

I would do it like this:

gpk - February 19, 2008 - 16:35

I would do it like this:

1. Copy the entire themes/garland folder to sites/all/themes/garland2 so that I'm working on a copy of the theme not the original
2. Create a PHP file template.php in the main garland2 folder containing:

<?php
function garland2_regions() {
 
$regions = phptemplate_regions();
 
$regions['header2'] = t('header 2');
  return
$regions;
}
?>

(but actually it's best to omit the closing ?>)

Then, in garland2's page.tpl.php, just before the line with </div> <!-- /header --> (i.e. just after the stuff about primary and secondary links), insert:

<div id="header2-region" class="clear-block"><?php print $header2; ?></div>

Then use CSS to control the positioning/layout of #header2-region. You can also put this line higher up in page.tpl.php if necessary to get the layout you want.

gpk
----
www.alexoria.co.uk

Thank you very much. This

rolandk - February 19, 2008 - 17:13

Thank you very much. This achieves the basic positioning that I require.

You mentioned "Then use CSS to control the positioning/layout of #header2-region."

Please can you elaborate a little on this ? Perhaps some sample code ?

Also how can I ensure that content in this region appears ONLY on my frontpage ?

>elaborate a little Well,

gpk - February 19, 2008 - 17:21

>elaborate a little

Well, this is basic CSS stuff. Have a look inside garland's style.css and look for #header-region to see how that is styled. You can similarly define the styling for #header2-region and control e.g. its vertical/horizontal alignment inside the containing <div id="header">. Maybe not necessary for your needs though.

http://www.w3.org/Style/CSS/

gpk
----
www.alexoria.co.uk

Thanks. Also how can I

rolandk - February 19, 2008 - 18:44

Thanks.

Also how can I ensure that content in this region appears ONLY on my frontpage ?

On the block's configuration

gpk - February 19, 2008 - 22:39

On the block's configuration page, under "Show block on specific pages:", enter <front>.

gpk
----
www.alexoria.co.uk

about the div trick

pnlnl - February 22, 2008 - 20:29

i think now that the mini panels should be able to do the trick without messing up too much with theming but as you said i think it depends on one's needs...

 
 

Drupal is a registered trademark of Dries Buytaert.