In the Administer/Site Building/Blocks menu, the javascript drag/drop fails to work if there are more than 20 items to arrange on the right sidebar section. It appears to move when drag/drop, but after save, it reverts to prior location. Workaround consists of turning off scripting and ordering with weight dropdowns boxes.

OS is debian (hosted at PowWeb)
PHP 5
Drupal 6.3

Comments

Babalu’s picture

Version: 6.3 » 6.6

i have more than 20 blocks and i can not sort them

maartenvg’s picture

Version: 6.6 » 7.x-dev
StatusFileSize
new73.31 KB

This is also present in HEAD. So let's fix it there first and then back port to 6.x-dev.

Attached is a screenshot which displayes the block ordering page with javascript disabled to visualize why ordering is irradic.

The blocks are being spread over the interval -10 to 10, and when there are more than 21 blocks in a single region, the last ones all receive a weight of 10. Those are ordered by alphabet if I'm not mistaken. It's not hard to imagine what happens when you move a block with a weight of 10 to a position also having weight 10: nothing.

A quick fix would be to broaden the range to something large like -100:100, but a more permanent fix would be to make the weight range adapt to the amount of blocks present.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new1.55 KB

Great catch. Patch attached counts number of blocks, divides it by two and then rounds up. Looks good here now.

maartenvg’s picture

StatusFileSize
new1.03 KB

Nice fix, didn't know about #delta.

Remarks
- Patch fixes the problem in d7 and d6.
- Introduces no problems as far as I can tell.

- Comments should end in a point.
- $number_of_blocks does not contain the number of blocks, but the (rounded) half of it. I suggest renaming it to something like $weight_delta.
- Isn't it better to do the determining of the delta in block_admin_display_form(), because $blocks is passed to that function anyway? That way you don't have to pass the variable, other modules/instances using block_admin_display_form() don't have to do their own calculations, and it is a smaller patch.

Attached is my proposal.

swentel’s picture

Status: Needs review » Reviewed & tested by the community

Good remarks, works still as intented, let's get this in !

Babalu’s picture

patch #4
Hunk #1 FAILED at 36.
Hunk #2 succeeded at 67 (offset 2 lines).

against drupal 6.6

maartenvg’s picture

the version in #4 does not apply against D6 anymore, we'll create a separate patch for D6 once it is fixed in D7.

swentel’s picture

@babalu, that's normal, we first fix things in HEAD, then backport.

Babalu’s picture

oh ok, sorry

dries’s picture

Status: Reviewed & tested by the community » Needs work

Let's extend the comment to explain why we need to divide by 2 and round. I thought that was odd.

maartenvg’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.15 KB

Changed to

+  // Weights range from -delta to +delta, so delta should be at least half
+  // of the amount of blocks present. This makes sure all blocks in the same
+  // region get an unique weight.
dries’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Needs work

I've committed this patch to CVS HEAD. It didn't apply against DRUPAL-6 so it needs a reroll. Updating the issue accordingly.

Thanks for the CVS HEAD patch, now let's get it into DRUPAL-6 too.

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new917 bytes

Reroll for D6

Babalu’s picture

juhuuuuuu works

maartenvg’s picture

Status: Needs review » Reviewed & tested by the community
dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to DRUPAL-6. Thanks folks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

natts’s picture

Version: 6.x-dev » 6.9
Status: Closed (fixed) » Needs work

I'm still having this problem with the latest Drupal version (6.9).

ssiaperas’s picture

Priority: Normal » Critical
Status: Needs work » Closed (won't fix)

I am having the same problem on a Drupal 6.9 site. I am unable to to change position by drag, drop, and save, or by weight and save. I am not receiving notification at the top of the blocks list page telling me that the blocks have been saved; it just refreshes the page. We have determined that this is a server issue of some sort, because we put a copy on a development server, and it worked perfectly. I have read some other forums that talk about the PHP Time Limit, which we had increased from 60 to 120, and that didn't seem to fix it. I've noticed some differences between our dev server and the live-site server; they are as follows:

dev server= Apache 2.2.11 and PHP 5.2.9 and MYSQL 5.0.67
live site server= Apache 1.3.41 and PHP 5.2.8 MYSQL 4.1.22

There are some other differences, but these are the big ones. Would these difference have anything to do with it?

ssiaperas’s picture

We have solved this issue on our site. The server had PHPSuHosin (http://www.hardened-php.net/suhosin/). Once this was disabled, we were able to save blocks again.

gpk’s picture

Priority: Critical » Normal
Status: Closed (won't fix) » Closed (fixed)

Resetting issue status, assuming that #18 is now resolved.

gpk’s picture