0

I had created a new region to my theme "buynow" and my theme.info contains the following line

regions[buynow] = Buynow

In my custom module i had created a custom block in which i assigned the block to the region buynow

function buynow_block_info() {
  $blocks = array();
  $blocks['buynow'] = array(
    'info' => t('Shoretel Buynow'),
    'status' => 1,
    'region' => 'buynow',
  );
  return $blocks;
}

When i try to enable the module, Iam getting The block was assigned to the invalid region and the block was disabled

How can i set my block to the new region.

2 Answers 2

0

You can use this code:

function formalter_block_info() {

 $blocks = array();

 $blocks['buynow'] = array(

 'info' => t('Shoretel Buynow'),

 'status' => 1, // This will enable your block by default, and set it to region given in 'region' option

 'region' => 'buynow', // put <machine-name of your region> in place of footer
 'visibility' => BLOCK_VISIBILITY_NOTLISTED,

 'weight' => 2,

 );
return $blocks;
}
8
  • Its not working Commented Jan 20, 2016 at 13:00
  • I tried this code, and it is working, what issue you are facing?
    – Dev
    Commented Jan 21, 2016 at 10:16
  • The block Buynow was assigned to the invalid region buynow_btn and has been disabled this is the error am getting. Commented Jan 21, 2016 at 13:14
  • I hope you are entering right region here: 'region' => 'buynow',
    – Dev
    Commented Jan 22, 2016 at 10:01
  • Yes my new region is buynow Commented Jan 22, 2016 at 10:08
0

Even though its an old issue I am pointing it to Drupal Discussion so others can benifit from it.

Here is the discussion regarding this in Drupal.org .

The problem occurs when the assigned region is not present in default themes.When we assign a region to a block through custom module it is assigned to all the available themes not just current active theme.

For example Seven is the administator theme in Drupal 7 , it has only 4 regions but default theme Bartik has more then 4 regions so if if you assign a region which is present in Bartik theme to block through custom module it cant get assigned to the same region in Seven theme as it is not present, hence the Warning will be thrown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.