How can I remove unused block from displaying. Such as "Powered by Drupal" block, I am trying to keep everything tidy in the admin and just want everything to be super clean.

Comments

tonicboy’s picture

Wow, you didn't even try a single thing before posting your question, did you? Every block has two options next to it, Region and Configure. Just change the region to or drag it to the Disabled region at the bottom.

krymp’s picture

That wasn't my question. I asked how to remove it from displaying...EVEN IN THE DISABLED SECTION!!!!!!!!!!!!!!! Sorry I didn't make that part clear enough, I just assumed people would understand.

Some custom blocks allow you to delete...but not the default blocks that come installed in drupal such as "Powered by Drupal"

nevets’s picture

You can only remove module provided blocks by disabling the module.

tonicboy’s picture

Why are you bothering to remove the block if it never appears on the website? You've explained it clearly enough and yet I still don't understand. Sounds like a waste of time to me.

krymp’s picture

Because I may not always be the user of the admin. So I dont want blocks that will never be used to display, even if its pushed into the unused portion. It's less options that another admin user has to deal with. So while it may sound like a waste of time to you, it would be a time saver for me because I dont have to go into the admin myself all the time. It just keeps everything super clean and organized.

nancydru’s picture

I take it you don't use aggregator or panels, bot of which can create a HUGE number of unused blocks. I have one Panels-based site whre the blocks page, mostly unused, takes 5 minutes to load. If you configure a block, then you have another 5 minutes before you can move it to a different region.

This is an excellent idea and probably belongs in the Utilities module, unless someone wants to create a whole module fo this.

vipaware’s picture

I have already added some time ago a similar feature request in Utilities module, see #798572: Hide Unused Blocks.

nancydru’s picture

I will see what I can do about it when I have time.

ColdSun’s picture

Wow tonicboy, you really didn't even try READING his post before replying, did you? Seriously though, he didn't ask how to disable. He asked how to remove. In the future, you're better off not posting than coming off in such a brash fashion.

zleef’s picture

I agree, this would be super helpful! Does anyone know how to do this?

Even Dawn’s picture

Since I was creating blocks trying to get DDBlocks working I have several versions of the same block name in the list I would like to be removed, not just disabled.

Aniara.io’s picture

I'd like a solution for this as well since the admin/build/block page is cluttered with blocks such as Who's Online/Who's New/Powered by Drupal etc and it takes a long time to render.

j4’s picture

I would also like to have this feature, I have Open Calais switched on and the number of Taxonomy blocks which I will never use is making my blocks page take a really long time to load. Would really ap[preicate help in this matter..

Thanks

Jaya

nancydru’s picture

You should start by opening a feature request with Open Calais to not make available the blocks you don't want to see. The same is true for any other module that makes a lot of never-used blocks. The true "cure" for this issue is prevention.

petu’s picture

subscribing

vipaware’s picture

subscribe

esme’s picture

subscribe

ohcray’s picture

subscribe

mattwmc’s picture

Sounds good to me!

What a pain in the arse it is to do anything with blocks!

Takes forever to load the page! Takes more time fooling around with the blocks page then it does building the site!

Maybe its a server thing though?

*Added - one thing you can do to remove blocks is through Views. Seems anytime I created a view a block was created as well. Click on "Block" then "Remove Display"

nancydru’s picture

Understanding the flow of Drupal can help you understand why such pages are so slow.

When you go to the Blocks admin page, every enabled module is invoked for what blocks it provides, then the database is updated with the resulting list. This is a HUGE overhead. I would, at the very least, prefer a button that says, "Rebuild the list" so that invoking all the modules is bypassed and the database only has to be read (which then means the list could be cached). But that is a core issue, which means that it would be pushed out to D8 at the earliest.

drupal.newbie’s picture

I was wondering how to do it just like you! Then with some playing around with my site files I figured out how to do it:

  1. It is pretty simple just open your site file manager, then go to the folder where your theme is - in my case it was "/htdocs/drupal/sites/all/themes/rootcandy".
  2. There you will find a ".info" file, open that file and there you can see regions[block_name]=block_title list where you can delete unused blocks from!



Good Luck !

BigMike’s picture

drupal.newbie,

Could you please explain how this works? Theme .info files are not updated when blocks are added therefore no block data exists within the .info file.

Could you provide an example on how to remove the "Powered by Drupal" block?

Thank you very much in advance!
BigMike

nancydru’s picture

Go to the Blocks admin page and set the region to "None."

BigMike’s picture

I already have many unused blocks -- unused means < none > Region -- and this does not remove the unused blocks as asked by krymp.

nancydru’s picture

And if you do remove the unused blocks, how would you ever enable one later on?

The best way to remove them is to not have the modules create them to start with.

BigMike’s picture

X2 to your comment on the module creation.

What if we had a collapsible field where unused and "never will be used" modules could be dragged to?

nancydru’s picture

I suppose one could insert a collapsed fieldset into the table (by taking over the theme function), but that won't make the page load any faster and would probably prevent dragging the block to another region (the drop down would still work). However, defining a new region ("Never") would cause those blocks to be executed, thus slowing down the whole site, unless a change to the block module is made.

mattwmc’s picture

That just contains the regions - not the blocks.

At least in my theme.info

lyosef’s picture

Having at least a place to tuck away unused/never will use blocks would help keep the block page organized and keep those of us who are new on the scene remain physically and mentally organized. Best would be the ability to remove these blocks altogether.

mattwmc’s picture

What I have been doing is disabling javascript whenever I view the blocks page.

Speeds things up a little bit, and doesn't reset the weight of everything.

BigMike’s picture

WOW This really speeds things up!! It also fixes my black table CSS issue described here.

nancydru’s picture

Interesting. I wonder if I can stack theme functions like I can submit handlers?

millions’s picture

subscribe

windy41’s picture

I use "Powered Drupal" block for example:
1: use hook_block_info_alter(&$blocks)
2: set

<?php
$blocks['system']['powered-by']['status'] = 1;
?>

3: Then click "save" in list block form ... the block hides
4: FINISHED

That means: the block will be enable but its region is -1 => Don't know where to show ... :)

xalexas’s picture

Copy block-admin-display-form.tpl.php from modules/blocks to your theme folder.

Add if($region!=-1): before this line: foreach ($block_listing[$region] as $delta => $data):

Of course you should add endif; afer endforeach;

Clear cache.

And thats it!

If yo want to remove only certain block you can use this preprocess function in template.php:

function YOURTHEMENAME_preprocess_block_admin_display_form(&$variables) {
unset($variables['block_listing']['-1']['system_0']);
}

(system_0 is name of Powered by Drupal block) use Devel module to find out module name

nancydru’s picture

Just keep in mind that this eliminates any possibility of enabling a block because you will not be able to see it.

xalexas’s picture

I agree, but if you want to disable blocks that you will never use you can use preprocess function in template.php.

Here is the list of blocks that I will never use:

  
function YOURTHEMENAME_preprocess_block_admin_display_form(&$variables) {
unset($variables['block_listing']['-1']['comment_0']);
unset($variables['block_listing']['-1']['user_0']);
unset($variables['block_listing']['-1']['user_1']);
unset($variables['block_listing']['-1']['user_2']);
unset($variables['block_listing']['-1']['user_3']);
unset($variables['block_listing']['-1']['context_ui_editor']);
unset($variables['block_listing']['-1']['admin_create']);
unset($variables['block_listing']['-1']['admin_account']);
unset($variables['block_listing']['-1']['admin_theme']);
unset($variables['block_listing']['-1']['admin_menu']);
unset($variables['block_listing']['-1']['locale_0']);
unset($variables['block_listing']['-1']['menu_primary-links']);
unset($variables['block_listing']['-1']['menu_secondary-links']);
unset($variables['block_listing']['-1']['menu_admin']);
unset($variables['block_listing']['-1']['menu_devel']);
unset($variables['block_listing']['-1']['context_ui_devel']);
unset($variables['block_listing']['-1']['admin_devel']);
unset($variables['block_listing']['-1']['tagadelic_0']);
unset($variables['block_listing']['-1']['tagadelic_1']);
unset($variables['block_listing']['-1']['tagadelic_2']);
unset($variables['block_listing']['-1']['tagadelic_3']);
unset($variables['block_listing']['-1']['tagadelic_4']);
unset($variables['block_listing']['-1']['tagadelic_5']);
unset($variables['block_listing']['-1']['devel_0']);
unset($variables['block_listing']['-1']['devel_2']);
unset($variables['block_listing']['-1']['profile_0']);
unset($variables['block_listing']['-1']['search_0']);
unset($variables['block_listing']['-1']['node_0']);
unset($variables['block_listing']['-1']['system_0']);
}

Note that I have disabled primary and secondary menus because I don't use them as blocks.
As you can see I have cleared a whole bunch of blocks! 29 useless blocks! And of course if you need to enable one of them just comment that line.

BigMike’s picture

I just setup the function YOURTHEMENAME_preprocess_block_admin_display_form method and it works great! Thanks!!

alexbk66-’s picture

subscribe.

Paul Lomax’s picture

This works the other way round, removing all modules by default and explicitly allowing them. Just add the module name to the array if it should be allowed.

/**
 * Preprocess for the block admin page, removes all unwanted blocks.
 *
 */
function theme_preprocess_block_admin_display_form(&$vars) {
  // List of modules which are allowed on the block page
  $show = array(
    'block',
    'menu',
  );
  // Scan through each block entry and remove ones that aren't needed.
  foreach ($vars['block_listing']['-1'] as $key => $disabled) {
    $type = explode('_', $key);
    if (!in_array($type[0], $show)) {
      unset($vars['block_listing']['-1'][$key]);
    }
  }
}
nancydru’s picture

For those who are on slower servers, be aware that this slightly increases CPU usage building the list, but cuts down on data transfer to the browser, which is probably the bigger problem.

blw0010’s picture

I copied and set up the block-admin-display-form.tpl.php like the comment above said.
Then I tried doing this in my theme's template.php:

function gcms_preprocess_block_admin_display_form(&$variables) {
	unset($variables['block_listing']['-1']['user_online']);
}

And it just hid everything in the disabled block section of the block administration page. Why is it hiding everything for me and not just the one block?

bradallenfisher’s picture

Then you won't have a messy block admin page? http://drupal.org/project/context
You will also gain some other UI benefits.

skaught’s picture

+1

alexecus’s picture

I know this is a very old thread, just opening it up for those with similar scenario.

You can, for any reason, remove the blocks on the admin page only. Please do note that this does not do anything rather than remove the block delta on the block list admin page

function hook_form_block_admin_display_form_alter(&$form)
{
    $deltas = array(
        'system_management',
        'menu_devel',
        'devel_execute_php',
        'devel_switch_user',
        'menu_features',
        'locale_language_content',
        'locale_language',
        'node_recent',
        'node_syndicate',
        'shortcut_shortcuts',
        'system_help',
        'system_navigation',
        'system_powered-by',
        'system_user-menu',
        'user_login',
        'user_new',
        'user_online',
    );

    foreach ($deltas as $delta) {
        unset( $form['blocks'][$delta] );
    }
}

Where $deltas will be an array of block deltas you want to remove.

Doing this approach, the original region of a specific block will be preserved. For example, that block is assigned to the header region, then you apply this code, It will still remain on the header region, but you won't see it in the block list page.

A specific use case for this is:

  • When you just want the block list admin page to be clean
  • Prevent a block from changing regions (like you do not want a disabled block to be enabled). This approach still requires you to prevent user access to the block delta configuration page itself.