Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
andregriffin CreditAttribution: andregriffin commentedI removed this comment because I posted non-functioning code. Refer to my comment below instead.
http://drupal.org/node/242107#comment-798428
Comment #2
aznboy CreditAttribution: aznboy commentedHI, 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.
Comment #3
andregriffin CreditAttribution: andregriffin commentedHeres 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:
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:
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:
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:
You need to replace "newregion" with what you named your region. The id, class and any other html can be changed to anything.
Comment #4
aznboy CreditAttribution: aznboy commentedOhhh..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.
Comment #5
andregriffin CreditAttribution: andregriffin commentedComment #6
aznboy CreditAttribution: aznboy commentedI should say that it worked perfectly the first time. Thank you again.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #8
halloffame CreditAttribution: halloffame commented...
Comment #9
andregriffin CreditAttribution: andregriffin commentedOnly 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.
Comment #10
andregriffin CreditAttribution: andregriffin commentedComment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #12
enaille CreditAttribution: enaille commentedI'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:
Suggestions?
Comment #13
enaille CreditAttribution: enaille commentedusing the panels module as we work around.... http://drupal.org/project/panels
Comment #14
andregriffin CreditAttribution: andregriffin commentedIt 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 tofloat: right;
then that should allow both regions to reside within the same row.Example:
Comment #15
andregriffin CreditAttribution: andregriffin commentedComment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #17
jrmorris@sbcglobal.net CreditAttribution: jrmorris@sbcglobal.net commentedIssue resolved,
Thanks for the documentation.
Comment #18
andregriffin CreditAttribution: andregriffin commentedif 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.
Comment #19
jrmorris@sbcglobal.net CreditAttribution: jrmorris@sbcglobal.net commentedThank you so much.
Not too bad, just had to put my code goggles on. Thanks again, huge help.
Comment #20
pzimmer CreditAttribution: pzimmer commentedGreat! 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
Comment #22
peddyfab CreditAttribution: peddyfab commentedHello 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
Comment #23
andregriffin CreditAttribution: andregriffin commentedIt 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.Comment #24
peddyfab CreditAttribution: peddyfab commentedComment #25
andregriffin CreditAttribution: andregriffin commentedHm, 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.
Comment #26
peddyfab CreditAttribution: peddyfab commentedHello andre,
MY NEW REGION =RESERVATIONS.I WANT TO BEABLE TO ADD MORE REGIONS AT THE TOPRIGHT OF MY PAGE.I DID THIS
Thank you andre.
Comment #27
Chanda Sampa CreditAttribution: Chanda Sampa commentedvery useful in formation..thank you very much guys:)
Comment #28
kpojeta CreditAttribution: kpojeta commentedI always assumed it would be much harder. These instructions were all very clear and helpful - thanks everyone. So easy. Now I can be dangerous ;-)
Comment #29
BigMike CreditAttribution: BigMike commentedThank you very much @#3 andregriffin.
Comment #30
olisb CreditAttribution: olisb commentedThanks andregriffin, that worked a treat :)
Comment #31
Dhipakkumaran CreditAttribution: Dhipakkumaran commentedhi 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.
print $header
please help where i made a mistake.