drupal_get_region_content()
returns the content that has been set with previous calls to drupal_add_region_content()
, but it doesn't include the content of the blocks, which are rendered in the page through block_page_build().
If you search for "drupal_add_region_content" in Drupal source code, you will notice that the function is called by:
drupal_get_region_content()
install_display_output()
template_preprocess_maintenance_page()
update_task_list()
What you set for the blocks in the administrative page is in which regions the blocks will be rendered, but their content is not added with drupal_add_region_content()
; in fact, none of the functions listed above (which are the only functions calling drupal_add_region_content()
, except the code for testing a Drupal installation) is for rendering/adding the block content.
If you need to render the blocks in your own code, you should check the code used in block_page_build()
. In particular, this is the code that is probably more useful for you:
// Fetch a list of regions for the current theme.
$all_regions = system_region_list($theme);
$item = menu_get_item();
if ($item['path'] != 'admin/structure/block/demo/' . $theme) {
// Load all region content assigned via blocks.
foreach (array_keys($all_regions) as $region) {
// Assign blocks to region.
if ($blocks = block_get_blocks_by_region($region)) {
$page[$region] = $blocks;
}
}
// …
}
The first two lines verify the page being shown is not the demo page used to show where the theme regions are placed.
If you need to render the blocks in a different way, it is more probable you are interested in overriding theme_block() in your theme, or (even more probably) creating a custom block.tpl.php template file. Another way to alter the way the blocks are rendered is to use a preprocess function for the blocks (hook_preprocess_block()).
drupal_set_region_content()
to set the region content?drupal_add_region_content()
but I see no point in it: I set regions' contents through the blocks admin interface.drupal_add_region_content()
.