After messing with the module and looking through the code, it seems that the main use of the "Use Menu Weight" option is to seed nodes' menu weights upon initially enabling Weights for a content type. I would like to use the menu weight as the canonical weight for the node, overriding any other changes to a node's weight field. In my particular use case, this would be useful for allowing the user to set weights using the built-in menu drag-and-drop interface. While the views drag-and-drop interface looks very handy, it won't work for me because I'm using a multi-level menu (I have another module handling the nested display for me). Perhaps no one else wants to do this, but it would be very useful to me.

Is there any interest in seeing the edits I've made to the weights.module file? I can attach a patch showing my work if there's any interest in developing this feature for Weights...


new2.73 KB

Ah, what the heck, I'll include the patch just for fun...

I added these functions:

  • weight_menu_link_insert($link)
  • weight_menu_link_update($link)
  • _weight_get_node_from_menu_link($link)
  • _weight_set_weight_from_menu_link($link)

And updated this function:

  • _weight_set_weight

I was under the impression that that is exactly what the "Use Menu Weight" did.

What I would expect from that option is for any changes to the menu weight to be reflected in the weight field. Short of applying this patch, can anyone clarify what the menu weight option is supposed to actually do?


I was just as surprised as you when I discovered that my changes to menu weights were being ignored except in their initial values when enabling the Weights module for a content type. I'm glad to hear someone else expected the Use Menu Weights setting to override Weights' own values -- that gives me hope that maybe I'm not entirely crazy!

Sorry about the extra comment; I seem to be having trouble getting my comment to thread under comment #2...

Patch looks good at first look. I should have time to test it out in the next couple days.

It's been working great for me so far, I hope it works for others too! I think the main feature it's missing is to hide the Weight vertical menu item in the node add/edit form, because I think it's clearer which weight is being used if only the menu weight is available when Use Menu Weight is selected. 10oclock, I'm hoping you know how to do that pretty easily? If not, I'll be happy to delve down into the code again and try to figure it out.

Patch seems to work for me! Thanks!

One minor note: if you do use this feature, make sure you use at least the +/- 50 range for your weights, since it appears that's what the Drupal menu system uses. I found this to be the case when I rearranged my menu links but everything only went to -20.

Thanks again!

Ooooh, that's a good point torgosPizza! I would suggest that if Use Menu Weights is checked, then range should be automatically set to +/-50 with no option to change it. Does that sound reasonable?

I think that would work, or at the very least some helpful messages with text describing that needs to be done. But perhaps the easiest option is some JS event that responds to the "use menu" selection, which disables the other range options, choosing the +/-50 for the user automatically.

Status:Active» Needs review
new4.34 KB

Here's an updated patch that incorporates the latest feedback. If someone can verify that it's working, I'll go ahead and commit it.

I've tried this using the latest dev, and while the patch went on without a hitch and the interface seems to work fine, it doesn't seem like any of the menu weights actually transfer across to the nodes. I've tried editing the menu and reordering items in it, and editing a node and saving it, and neither of these causes the sort of items in the view to change. 'Content: Sticky (desc)' is the only sort criterion, so I'm a bit lost as to what could be going wrong. Latest releases of Drupal, Views, CTools etc. and latest dev of Weight. Ho hum *scratches head*.

Whoa wait a minute. I've manually checked the weights for each node, and they match the menu weights. There's an issue with my view that's causing it to completely ignore sorting on the 'Content: Sticky (desc)' field. Other fields will sort fine, but that one is doing nothing, and recreating doesn't help. Oh dear.

Working fine. This is what I get for following instructions from issues that were closed two or more years ago. Didn't realise there was a separate weight field in the views fields nowadays. Apologies for spamming the issue queue, but it's all working just dandy at this end now I've got over the initial hurdle. Does that count as a test?

Status:Needs review» Fixed

Thanks for testing! Committed to 7.x-2.x.

Status:Fixed» Closed (fixed)

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