tags:

views:

174

answers:

3

The person managing a site I'm working on wants to be able to decide what blocks go where. There is already a nice interface for this in Drupal (selecting the region from a drop down) but I'd like to hide certain blocks from this user. These are blocks he should not be able to move around.

Afaik this is not possible via the Permissions. Is there a module that allows fine grained control of what blocks can be managed by whom? I'd rather not write a custom interface ...

Thanks, Stef

A: 

Take those blocks out of regions and embed them into your template manually using module_invoke().

$block = module_invoke('module_name', 'block', 'view', 'block name or ID');

print '<h2>' . $block['subject'] . '</h2>';
print $block['content'];
ceejayoz
how would this help a webmaster manage those blocks?
stef
sorry, i see what you mean: hiding the "disallowed" blocks in the templates, got it. if there is another option id like to hear it otherwise this is acceptable for the answer
stef
A: 

Maybe give Blockqueue a try? I've never used it, but it appears to cover your use case.

Grayside
Doesn't look like that permits the locking down of specific blocks.
ceejayoz
You are correct. Looking at the code, my impression that there were separate permissions for adding to and editing the queue is wrong. That could be changed, but the theme approach is probably easier.
Grayside
+2  A: 

Well, you can create a simple custom module like this (replace my_module with your custom module's name, obviously):

    function my_module_perm()
    {
        return array('view special blocks');
    }   



    function my_module_form_alter(&$form, &$form_state, $form_id) {
      if ($form_id == 'block_admin_display_form') {
        if(!user_access('view special blocks')) {
            $special_blocks = array( ); // Specially hidden blocks go here

            foreach($special_blocks as $block) {
                unset($form[$block]);
            }
        }
      }
    }

And then:

  1. Add the blocks you want to hide into the $special_blocks array (it's basically the id of the block's div minus block_ )
  2. Create a new account, and possibly a new role for this guy
  3. Permission-wise, the new user's role should have access administration pages and administer blocks on, but shouldn't have view special blocks

Tested on Drupal 6.6, should work on other 6.x versions (and maybe 5.x with a few modifications)

Eli Krupitsky

related questions