Setting the region in hook_block
I have a theme that contains the region content_bottom. The region appears in the select boxes at admin/settings/block. I have a module that implements hook_block with: function mymodule_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[block1] = array( 'info' => 'Block 1', 'cache' => BLOCK_CACHE_GLOBAL, 'weight' => -1, 'status' => 1, 'visibility' => 1, 'region' => 'content_bottom', 'pages' => '<front>', ); return $blocks; and the block always appears in the disabled list. I tried using TRUE instead of 1 for status, which shouldn't make a difference, and didn't. The docs don't actually give an example of using region, other than saying you can, and a grep of 'region' starting at the document root in a module-laden sandbox seems to come up empty, so I'm not quite sure where to look. Jeff
If I recall correctly, these settings are only taken into account on 1st installation of the module (i.e. if there isn't an entry yet in the table {blocks} for this module-delta combination). Did you perhaps install the module first, before setting the visibility & region parameter? If so, you might want to try to reinstall the module or remove the entry from the blocks table. If it's for a contrib module where you want to change the default settings (but i guess not), you'd have to alter the entry in {blocks} through hook_update_X(). Sven On Thu, Jul 8, 2010 at 6:36 PM, Jeff Greenberg <jeff@ayendesigns.com> wrote:
I have a theme that contains the region content_bottom. The region appears in the select boxes at admin/settings/block. I have a module that implements hook_block with:
function mymodule_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[block1] = array( 'info' => 'Block 1', 'cache' => BLOCK_CACHE_GLOBAL, 'weight' => -1, 'status' => 1, 'visibility' => 1, 'region' => 'content_bottom', 'pages' => '<front>', ); return $blocks;
and the block always appears in the disabled list. I tried using TRUE instead of 1 for status, which shouldn't make a difference, and didn't. The docs don't actually give an example of using region, other than saying you can, and a grep of 'region' starting at the document root in a module-laden sandbox seems to come up empty, so I'm not quite sure where to look.
Jeff
That was it. Thanks, Sven. On 7/8/2010 1:34 PM, Sven Decabooter wrote:
If I recall correctly, these settings are only taken into account on 1st installation of the module (i.e. if there isn't an entry yet in the table {blocks} for this module-delta combination). Did you perhaps install the module first, before setting the visibility & region parameter? If so, you might want to try to reinstall the module or remove the entry from the blocks table.
participants (2)
-
Jeff Greenberg -
Sven Decabooter