Drupal 7 Blocks Are Getting Out of Order

I was asked to add a right hand rail promo block to a Drupal 7 site. This should be super easy right? Ya – I thought so too.

When I tried to do so I encountered this odd peculiar issue. I created the block, went into context and then went to edit the homepage block. I added the promo block to the right rail and saved out.

When I went to verify my change I discovered that the blocks on the main content section were all out of order even though I had not altered these. It’s like someone said ha ha I am going to mix up all of your blocks and poof, all of the blocks were out of order and making the page look like a jumbled up mess.

Trying to add blocks using context is causing all the other block assignments for the context to break.

The fix is pretty easy once you know what the solution is. So here is the solution

Systems Administrator to update the production /settings.php file with the line: $conf[‘drupal_weight_select_max’] = 1000;

The problem was the new code introduced in form.inc in drupal 7.12 that switches between select or textfield for the weights. The problem seems to be when you save some context it does not retrieve the numbers from the input field(textfield) thus serializing the array with all weights as NULL.

I found out that you could set the variable ‘drupal_weight_select_max’ to something higher than 100 it solves the problem.

So if someone encounters this problem you can set the variable in the database either by using variable_set or with an insert in MySql to a high number. I set my variable to 1000 and the context was able to save normally with nomal weights.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.