Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:44:35+00:00 2026-05-31T15:44:35+00:00

During the install of a module, I need to assign a View to a

  • 0

During the install of a module, I need to assign a View to a Region, and unassign a Block from that region. It’s something that would take 3 seconds in the UI, but this has to be done programmatically.

The view is called ‘legal-footer’ and it needs to be assigned to the region ‘footer’.
Similarly, I have a block called ‘footer-logos’ that’s currently in the ‘footer’ region but needs to be removed.

I think I want hook_block_info_alter, but I’m not sure if it works on a View, and there’s a note in the API docs that it can’t be used to unassign a block…

I’m new to Drupal, and I can whatever I want in the UI pretty easily, but I’m having a hard time with the API.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:44:36+00:00Added an answer on May 31, 2026 at 3:44 pm

    to assign block to a region use ‘region’ key in the array returned info that contain the name of the region that this block should be assigned to

    E.g

    function module_block_info() {
        $blocks = array();
        $blocks[0] = array(
            'info' => t('Block Title'),
            'region' => 'name-of-the-region', // here is the name of the region
            'status' => 1, // 1 if you want the block to be enabled by default
        );
        return $blocks;
    }
    

    and you can Disable exist block by using such query

    db_update('block')->fields(array('region' => '', 'status' => 0))->condition('bid', $block_id)->execute();
    

    replace $block_id with the id of the block that you want to disable

    UPDATE:
    you can use hook_block_info_alter to disable exist block

    function hook_block_info_alter(&$blocks, $theme, $code_blocks) {
      // Disable the login block.
      $blocks['defining_module']['delta']['status'] = 0;
    }
    

    good luck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to change the values for this section during the install, specifically the
I need to make a file read/write for all users during install. Right now,
During install, I would like to play a .wav or .mp3 (using Media Player
Can I ask the user WHERE to install the application during install time? Most
I have a command line I want to run during the install of a
I'm working on an installer project, during the install process I'd like the user
I've searched around online but can't find what I'm after. Basically, during an install,
I am trying to install RedMine on a server. During the procedures as explained
I'd like a module to install some content, for instance add some static blocks
I am attempting to install an application. During compilation it fails with the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.