Hi, I reviewed the drupal handbook for adding regions/blocks but when I looked in the template file it was totally different from the steps describe on how to add new regions. Basically I want to move the content block to the top instead of the bottom and add a right and left region to the bottom.

Is there an example on how to do this with using framework as the base as I like it's clean look and all.

Thanks.

Comments

andregriffin’s picture

I removed this comment because I posted non-functioning code. Refer to my comment below instead.

http://drupal.org/node/242107#comment-798428

aznboy’s picture

HI, thanks for responding.

Umm..I looked in the template.info file and did not see that which is why I posted. i read that you can just create it and it will be picked up by drupal but when I tried I got a blank page. Maybe I'm just not seeing the answer right in front of me as usual.

To clear it up what I'm trying to do is to but a block above the content in the content area or the middle container.

The module I'm using is Tagdelic which holds all the tags that I'm creating for pages about how to write a book.

I tried using the regular block method with a -10 but still the block shows up at the bottom of the contents on the node page which shows all the nodes that I created using the page and book module as I'm trying to keep the site from loading to many modules as my web hosting is pretty sorry at site5 in terms of speed and performance.

Thanks for all your help and this clean template.

andregriffin’s picture

Heres how to add regions for both Drupal 5.x and 6.x

To add regions for Drupal 5.x

ADD this code in its entirety to the bottom of your template.php file:

/** Define the regions **/
function framework_regions() {
  return array(
      'left' => t('left sidebar'),
      'right' => t('right sidebar'),
      'content' => t('content'),
      'header' => t('header'),
      'footer' => t('footer'),
      'newregion' => t('new region'),
  );
}

Replace "newregion" with what you would like to call that region instead. Note that the name on the left before the = is the machine readable format, and cannot have spaces. the name after the = is the human readable format, and can have spaces, capital letters etc. You may add as many regions as you like in the same manner that "newregion" has been added in the example above.

Then, in your page.tpl.php file, define where you would like you regions to be using a print call like so:

<?php if ($newregion): ?>
  <div id="new-region" class="region">
    <?php print $newregion ?>
  </div>
<?php endif; ?>

You need to replace "newregion" with what you named your region. The id, class and any other html can be changed to anything.

To add regions for Drupal 6.x

ADD the following code to you themename.info file:

regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[newregion] = New Region

The internal "machine" readable name in square brackets and the human readable name as the value, e.g., regions[theRegion] = The region label.

The contents of the .info file is cached in the database so altering it will not be noticed by Drupal. To clear it, do ONE of the following:

1. Clear button located at "Administer > Site configuration > Performance".
2. With devel block enabled (comes with devel module), click the "Empty cache" link.
3. Simply visit the theme select page at "Administer > Site building > Themes".

Then, in your page.tpl.php file, define where you would like you regions to be using a print call like so:

<?php if ($newregion): ?>
  <div id="new-region" class="region">
    <?php print $newregion ?>
  </div>
<?php endif; ?>

You need to replace "newregion" with what you named your region. The id, class and any other html can be changed to anything.

aznboy’s picture

Ohhh..add the whole snippet to the file. I though I was just looking to add this line "'newregion' => t('new region')," to the file and the rest of the code was suppose to be pre-existing. I'm pretty sure now I can get it to show the extra region. Thanks so much for you help and patience. Good work on the template.

andregriffin’s picture

Status: Active » Fixed
aznboy’s picture

I should say that it worked perfectly the first time. Thank you again.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

halloffame’s picture

...

andregriffin’s picture

Only in the event you have nothing in that region, and thus would like not to display it and/or it's containing div wrapper, you would use the "if" statement.
If you want to just always print that region, you can do so directly.

andregriffin’s picture

Status: Closed (fixed) » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

enaille’s picture

Status: Closed (fixed) » Active

I've added a region above the content region and would like to break up the new region into two regions. This would be like a single row with two equal columns, each column being it's own region. Is this possible?

I would like to add:

'topcontentleft' => t('top content left'),
'topcontentright' => t('top content right),

Suggestions?

enaille’s picture

using the panels module as we work around.... http://drupal.org/project/panels

andregriffin’s picture

It sounds like you just want to add two regions to above the content region. Unstyled, one would be below the other and both would be as wide as the content area. However, if you use CSS to set the width of both regions to 50% or less, then set one to float: left; and the other to float: right; then that should allow both regions to reside within the same row.

Example:

#region1 {
  float: left;
  width: 48%;
}

#region2 {
  float: right;
  width: 48%;
}
andregriffin’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jrmorris@sbcglobal.net’s picture

Issue resolved,

Thanks for the documentation.

andregriffin’s picture

if you want to create a new region, you can place that code anywhere you want the region to show up (usually in page.tpl.php). if you place it inside a containing div, it will show up in whatever order calls are made within that containing div.

jrmorris@sbcglobal.net’s picture

Thank you so much.

Not too bad, just had to put my code goggles on. Thanks again, huge help.

pzimmer’s picture

Great! I followed andregriffin's instructions in thread #3 and it worked like a charm in 6.19. I needed a right region where there was none, just on certain pages, so I configured the new right sidebar block to appear only on selected pages. Thanks

peddyfab’s picture

Hello Andre,
The code workout fine..thanks
I was able to create a new region on my front page,it appeard at the topleft of my site ontop of my logo.My problem is i want this region at the topleft side.Please i will so much appreciate if you or anyone can assist me with a code to do that.Am still a fresher......
Thanks

andregriffin’s picture

It depends on where you placed it in your the structure of your template file. You may also want to add the class="clearfix" to the containing element of your new region. If you can post your template code and describe a little better where you want the region to show up, maybe i can help.

peddyfab’s picture

andregriffin’s picture

Hm, it seems you need to enclose your code with < code > < /code > tags in your post so i can see the HTML in your post. Also, that doesn't look like the Framework template. You probably just need to print the region within the header of your template either before or after the logo/site-name and float-left with class="clearfix" added to the containing element.

peddyfab’s picture

Hello andre,
MY NEW REGION =RESERVATIONS.I WANT TO BEABLE TO ADD MORE REGIONS AT THE TOPRIGHT OF MY PAGE.I DID THIS

</head>
<?php if ($reservations): ?>
  <div id="reservations" class="art-reservations"></div>
<div class="float-right"></div>
    <?php print $reservations ?>

Thank you andre.

<head>
  <?php echo $head; ?>
  <title><?php if (isset($head_title )) { echo $head_title; } ?></title>  
  <?php echo $styles ?>
  <?php echo $scripts ?>
  <!--[if IE 6]><link rel="stylesheet" href="<?php echo $base_path . $directory; ?

>/style.ie6.css" type="text/css" /><![endif]-->  
  <!--[if IE 7]><link rel="stylesheet" href="<?php echo $base_path . $directory; ?

>/style.ie7.css" type="text/css" media="screen" /><![endif]-->
  <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE 

*/ ?> </script>
</head>
<?php if ($reservations): ?>
  <div id="reservations" class="art-reservations"></div>
<div class="float-right"></div>
    <?php print $reservations ?>
  
<?php endif; ?>



<body>
<div id="art-main">
<div class="art-sheet">
    <div class="art-sheet-body">
<div class="art-header">
    <div class="art-header-jpeg"></div>
<div class="art-logo">
     <?php   if (!empty($site_name)) { echo '<h1 class="art-logo-name"><a 

href="'.check_url($front_page).'" title = "'.$site_name.'">'.$site_name.'</a></h1>'; } ?>
     <?php   if (!empty($site_slogan)) { echo '<div class="art-logo-text">'.

$site_slogan.'</div>'; } ?>
</div>

</div>
<?php if (!empty($navigation)): ?>
<div class="art-nav">
    <div class="l"></div>
    <div class="r"></div>
    <?php echo $navigation; ?>
</div>
<?php endif;?>
<?php if (!empty($banner1)) { echo '<div id="banner1">'.$banner1.'</div>'; } ?>
<?php echo art_placeholders_output($top1, $top2, $top3); ?>
<div class="art-content-layout">
    <div class="art-content-layout-row">
<?php $art_sidebar_left = (isset($left) && !empty($left)) ? $left : $sidebar_left ;
if (!empty($art_sidebar_left) || !empty($vnavigation_left)) echo '<div 

class="'.art_get_sidebar_style($art_sidebar_left, $vnavigation_left, 'art-sidebar1').'">' 

. $vnavigation_left . $art_sidebar_left . "</div>"; ?>
<div class="<?php $art_sidebar_left = (isset($left) && !empty($left)) ? $left : 

$sidebar_left;
$art_sidebar_right = (isset($right) && !empty($right)) ? $right : $sidebar_right;
echo art_get_content_cell_style($art_sidebar_left, $vnavigation_left, $art_sidebar_right, 

$vnavigation_right, $content); ?>">
<?php if (!empty($banner2)) { echo '<div id="banner2">'.$banner2.'</div>'; } ?>
<?php if ((!empty($user1)) && (!empty($user2))) : ?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td class="half-width"><?php echo $user1; ?></td>
<td><?php echo $user2; ?></td></tr>
</table>
<?php else: ?>
<?php if (!empty($user1)) { echo '<div id="user1">'.$user1.'</div>'; }?>
<?php if (!empty($user2)) { echo '<div id="user2">'.$user2.'</div>'; }?>
<?php endif; ?>
<?php if (!empty($banner3)) { echo '<div id="banner3">'.$banner3.'</div>'; } ?>
<?php if (!empty($breadcrumb)) { echo $breadcrumb; } ?>
<?php if (($is_front) || (isset($node) && isset($node->nid))): ?>              
<?php if (!empty($tabs) || !empty($tabs2)): ?>
<div class="art-post">
    <div class="art-post-body">
<div class="art-post-inner">
<div class="art-postcontent">
    <!-- article-content -->
<?php if (!empty($tabs)) { echo $tabs.'<div class="cleared"></div>'; }; ?>
<?php if (!empty($tabs2)) { echo $tabs2.'<div class="cleared"></div>'; } ?>

    <!-- /article-content -->
</div>
<div class="cleared"></div>

</div>

    </div>
</div>
<?php endif; ?>
<?php if (!empty($mission)) { echo '<div id="mission">'.$mission.'</div>'; }; ?>
<?php if (!empty($help)) { echo $help; } ?>
<?php if (!empty($messages)) { echo $messages; } ?>
<?php $art_post_position = strpos($content, "art-post"); ?>
<?php if ($art_post_position === FALSE): ?>
<div class="art-post">
    <div class="art-post-body">
<div class="art-post-inner">
<div class="art-postcontent">
    <!-- article-content -->
<?php endif; ?>
<?php echo art_content_replace($content); ?>
<?php if ($art_post_position === FALSE): ?>

    <!-- /article-content -->
</div>
<div class="cleared"></div>

</div>

    </div>
</div>
<?php endif; ?>
<?php else: ?>
<div class="art-post">
    <div class="art-post-body">
<div class="art-post-inner">
<div class="art-postcontent">
    <!-- article-content -->
<?php if (!empty($title)): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title 

.'</h2>'; endif; ?>
<?php if (!empty($tabs)) { echo $tabs.'<div class="cleared"></div>'; }; ?>
<?php if (!empty($tabs2)) { echo $tabs2.'<div class="cleared"></div>'; } ?>
<?php if (!empty($mission)) { echo '<div id="mission">'.$mission.'</div>'; }; ?>
<?php if (!empty($help)) { echo $help; } ?>
<?php if (!empty($messages)) { echo $messages; } ?>
<?php echo art_content_replace($content); ?>

    <!-- /article-content -->
</div>
<div class="cleared"></div>

</div>

    </div>
</div>
<?php endif; ?>
<?php if (!empty($banner4)) { echo '<div id="banner4">'.$banner4.'</div>'; } ?>
<?php if (!empty($user3) && !empty($user4)) : ?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td class="half-width"><?php echo $user3; ?></td>
<td><?php echo $user4; ?></td></tr>
</table>
<?php else: ?>
<?php if (!empty($user3)) { echo '<div id="user1">'.$user3.'</div>'; }?>
<?php if (!empty($user4)) { echo '<div id="user2">'.$user4.'</div>'; }?>
<?php endif; ?>
<?php if (!empty($banner5)) { echo '<div id="banner5">'.$banner5.'</div>'; } ?>
</div>
<?php $art_sidebar_right = (isset($right) && !empty($right)) ? $right : $sidebar_right;
if (!empty($art_sidebar_right) || !empty($vnavigation_right)) echo '<div 

class="'.art_get_sidebar_style($art_sidebar_right, $vnavigation_right, 'art-

sidebar2').'">' . $vnavigation_right . $art_sidebar_right . "</div>"; ?>

    </div>
</div>
Chanda Sampa’s picture

Component: Code » CSS/HTML markup

very useful in formation..thank you very much guys:)

kpojeta’s picture

I always assumed it would be much harder. These instructions were all very clear and helpful - thanks everyone. So easy. Now I can be dangerous ;-)

BigMike’s picture

Thank you very much @#3 andregriffin.

olisb’s picture

Thanks andregriffin, that worked a treat :)

Dhipakkumaran’s picture

hi friends,

I am new to drupal. I try to create a new region in block.

In theme.info i added a block header
regions[left] = Left sidebar
regions[right] = Right sidebar
region[header] = Header
regions[content] = content
regions[footer] = Footer
regions[custom] = Custom

In page.tpl.php i added the below script. but header block is not appearing, even i clear the cache under admin/settings/performance.

please help where i made a mistake.