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

Comments

jwolf’s picture

p0732658’s picture

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.

jwolf’s picture

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".

p0732658’s picture

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

p0732658’s picture

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 ?

hsalazar’s picture

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.

p0732658’s picture

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

dkdev’s picture

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

Seems to be working.

gpk’s picture

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;
}
faqing’s picture

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

faqing’s picture

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.

jiangxijay’s picture

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

Works great!

rolandk’s picture

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

rolandk’s picture

anyone ?

vkr11’s picture

subscribe

faqing’s picture

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

gpk’s picture

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

rolandk’s picture

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

gpk’s picture

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:

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

rolandk’s picture

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 ?

gpk’s picture

>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

rolandk’s picture

Thanks.

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

gpk’s picture

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

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

pnlnl’s picture

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...

andrea.cavattoni’s picture

if someone wants to know how to do that in derupal six and above:

For display a block before the node you have just to add a new region in your theme, for example pluralism, go in the theme directory (sitename/themes/pluralism) and in the file pluralism.info in the follow lines:

regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer

add a new line called blocks.
After that you'll have something like:

regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[blocks] = blocks

Now you have just to clean the cache (Administration>Site building>themes>Apply)
and add

<?php print $blocks ?>

in page.tpl.php before

<?php print $content; ?>

Now you have just to go in the Blocks Administration and chose a block, afther thatin the sectors chose blocks,
Now you'll display before the block and after node

Enjoy;-)