The new block options are terrific. I have added a block (small banner ad) to the content area of Drupal 4.7RC1. But it shows at the bottom of all the content. Is there a way to specify that the block shows BEFORE the content, at the top of the page?

Comments

jodo’s picture

In the theme's page.tpl.php file find and move or paste print $header; into the section above print $content;

Then in admin/block make sure the banner block or any block you choose or create is enabled and the placement is in header.

Chivalrybean’s picture

Another way to do this is to open the page.tpl.php for the theme you are using, then just below the line <?php if ($mission) { ?><?php print $mission ?><?php } ?> paste whatever code you need. This worked for me.

I wrote an article about it on by Drupal blog: http://thebeandom.com/drupal/?q=node/49

weigang’s picture

If the block is $test_block.
In the show.tpl.php file,use this

print $test_block;

_________________________________________________
I like 诛仙私服

styro’s picture

I haven't quite figured it out myself yet :)

It seems that the 'content' region is a little ambiguous. Maybe 'before content' and 'after content' might be better region names?

--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Example Knowledge Base built using Drupal

hip’s picture

I'd like to be able to create new block areas that can be managed from the administration panel (admin/block) just as 'Left sidebar' and 'Right sidebar' are.

As it is not yet implemented it should be arranged manually first. I guess we (maybe) had to modify some values in the DB (1), redefine/create some template functions (I make use of PHPTemplate) (2) and then define the areas within the template itself + style it in the CSS file (3).

(1) goes for it to appear in the admin block section
(2) for the selected blocks to be read and processed by the template engine
(3) for the block contents (whatever) to be set and style in the right place within the webpage

Do you know how to do it?

I'm assuming for your post that you're doing something similar on Drupal 4.7. I'm developing a site on last stable Drupal 4.6.

Thanx in advance,
hip

PakWaan’s picture

Several new block areas are already built in to Drupal 4.7. You can add blocks to the header, footer and content areas. Rather than spend the time and energy trying to re-create the wheel, I'd probably upgrade to Drupal 4.7..... RC3 is quite stable and I haven't found any serious issues.

hip’s picture

I found out a way for Drupal 4.6. It is template based and quite easy to implement. I just had to include the module_invoke() function whereever I wanted within the PHP code in my templates, inside a conditional bracket if needed. Easy peasy. :-)

So to include the 'search module' right at the beginnig of a document I would write

...
<head>
<?php
  $block = module_invoke('search', 'block', 'view', 0);
  $output = $block['content'];
  print $output;
?>
...

It is not administered from the admin control panel, as Drupal 4.7 announces to be, but it DOES the trick. I'm not code afraid (though not being no kind of geek nor a programmer ;-) )

Good luck,
hip

(Much) better documented at: http://drupal.org/node/26502
Some extra info about 'module_invoke(): http://drupal.org/node/51900

Plaguester’s picture

I know that 4.7 has more block areas, but one of my sites is already using them all, and would like more. I was under the impression that adding new block areas was a feature of 4.7. Does anyone know?

styro’s picture

Explained here: http://drupal.org/node/29139

Some of the 3rd party themes for 4.7 already to this - I can't remember the name but one of them had no left region, but two different right regions.

--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Example Knowledge Base built using Drupal

Anonymous’s picture

Hi there! I am at a loss right now. Completely! I managed to create a region, thanks to the instructions as mentioned (http://drupal.org/node/29139). Great. Now I want to add a text field under "create content", and "edit content" so I can put custom html formatted content (code for Commission Junction ads, actually) to that targetted block, specific to each page. I can't find any reference on how to do that. If it's out there to be found, then I can't see or understand it. Can anyone direct me to enlightenment?? Is there a module I should use?

Anyone's help would be hugely appreciated as I am getting really frustrated with this!

Sonia Graphics
using - Drupal 5.7

styro’s picture

Note: I'm assuming (because I haven't looked) that there isn't an ad handling contrib module already written that does exactly what you want...

You haven't found a reference for that because it is a specific custom requirement. Most of the time a specific custom requirement is achieved by breaking it down into a series of simpler more general parts.

The most basic method with no custom coding would be to create a new block for each ad, and specify the page(s) it appears on. Now this could quickly get hard to manage once the number of these blocks gets too high, but it does let you assign each bit of content to more than one page.

But you won't get an item in the create content menu (that menu is only for node types not blocks) or a way to use a nodes edit tab with that method. Ask yourself if you really need it to work that way?

Or if the create content / edit tab is important (assuming this is just some HTML at the top of each node), you don't have to use blocks and regions, you could just use CCK to create a field for it. Reusing the same content on multiple nodes would be more painful though, and the content now gets stored as part of the node - which you might not want. Your themes node templates would be customised to present this field how you'd like it.

If neither of those options is enough, you would probably need a custom module to fulfill all your requirements or to get away with just one block. This module could do things like create database tables and forms (at the appropriate menu locations) for storing this content and the pages each bit of content should appear on. The module would also contain a block that examines the current page and retrieves the appropriate content.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

hugafish’s picture

I would like to be able to do this with out using php snippets. Most header areas were not intended to be thick from top to bottom, hence there name header. Most headers are a few inches high via eyeball measurement ha. this is for design reasons. therefore it would really be nice to be able to add a block to the header area and have the weights that you assign go from left to right instead of from top to bottom. This should be a design feature of Drupal or perhaps the garland them I am using. What you have to do now is custom code or html or css, I think by design if you would like to include lets say three different blocks into the header area they should be weighted from left to right instead of them being stacked on top of each other. Does this make any since or am I just off my rocker here. Well I'm always off my rocker so that is irrelevant I guess. Just my thoughts on design the way I see it should be. I'm not saying that you shouldn't have control via weight for top to bottom though perhaps instead of weight maybe use an X Y coordinate approach or something giving you more placement control of blocks.

styro’s picture

you could probably do that just with CSS. Eg if you have three blocks in the header, give the blocks a width of 30% (or whatever) then float them or position them etc.

The weight will determine the order in which they appear in the HTML - your theme CSS should then be able to display them how you want. Without any special styling that just means a vertical top to bottom order with full width block elements but you can change that to left to right etc with CSS.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

blueflowers’s picture

here is the solution to add 'new template regions' for your site... Found this on the net, slightly modified it but can't give credit to the author as I didn't keep track of their name or url

-----------------------------------------------------------------

add this snippet to template.php replacing themeName with your site's theme name and newRegion with what you'd like to call the new region - Don't forget to give it a memorable name as this name will be used when the regions are presented to admins, simply replace new region name with your new region's memorable name.

function themeName_regions()
{
return array(
"left"=>t("left sidebar"),
"right"=>t("right sidebar"),
"content"=>t("content area"),
"header"=>t("site header"),
"footer"=>t("site footer"),
"newRegion"=>t("new region name")
);

}

now open page.tpl.php

put in the following where you would like your new region to appear

print $newRegion;

obviously replacing newRegion with whatever you called the newRegion in template.php

Hope someone finds this useful.

styro’s picture

In case anyone is wondering that isn't so much a "snippet found on the net" as the official (a new feature in 4.7) PHPTemplate way to add new regions :)

ie the docs for it (and more) are here: http://drupal.org/node/29139 (previously linked to in this thread).

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

gprang’s picture

The above is exactly what I would like to do (in my case, keep a block always above content) but has anyone figured out how to do this in 6.0? If I can figure it out I will post, but I don't have much knowledge of the code.