[development] finding blocks and getting them simpler.
Khalid B
kb at 2bits.com
Mon May 15 15:05:09 UTC 2006
On 5/15/06, Bèr Kessels <ber at webschuur.com> wrote:
> Hello list,
>
> One thing that has bothered me for a long time, is how to get/find/parse
> blocks in a simple way.
>
> Problems are:
> * you need to read the code to find the "delta". Modules like views require
> you to hover the admin/blocks/edit links in order to find the delta.
> * a block returned by hook_block('view') needs casting and remodelling before
> I can be passed to theme_block.
>
> I addressed the last point with a helper function get_block.
>
> But that function still has the first problem above: You need to know a) the
> module that makes the block and b) the delta.
>
> Does anyone know a trick for this? Or did I miss an API function? Is someone
> working on code for this?
>
> NOTE: I am not particularly interested in a discussion to revise the core
> block architecture. Eventhough that might be an interesting project, I am
> looking for an intermediate function/api-set right now :)
Initially, I used flexiblock to get the blocks I wanted where I want them (e.g.
adsense blocks),
Later, I decided that less dependancies is better, and to do it
directly from core.
In 4.7, there is the block regions stuff, which should work great
(more on that below).
Like Ber and Merlin, I find myself using the delta too. In template.php, I find
myself doing this:
function phptemplate_get_block($block_id) {
$block = block_block('view', $block_id);
return $block['content'];
}
Then in node/page.tpl.php I do:
<?php print phptemplate_get_block(6); ?>
Not pretty, and has hard coded block deltas, but it works.
The reason is, I don't want the block title to be displayed. I know that this
can be handled with CSS, but prefer not to have it altogether.
So on my to do list, there is a task to make it an option to turn off
the display
of a block's title.
Now that block regions can be anywhere, they can be in all sorts of crazy
places.
In such situations, the display of the title should be turned off for
the region.
More information about the development
mailing list