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...

Comments

ScratchFury’s picture

StatusFileSize
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
darksnow’s picture

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?

Cheers.

ScratchFury’s picture

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!

ScratchFury’s picture

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

davisben’s picture

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

ScratchFury’s picture

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.

torgosPizza’s picture

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!

ScratchFury’s picture

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?

torgosPizza’s picture

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.

davisben’s picture

Status:Active» Needs review
StatusFileSize
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.

DanielJohnston’s picture

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*.

DanielJohnston’s picture

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.

DanielJohnston’s picture

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?

davisben’s picture

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.

knalstaaf’s picture

Version:7.x-2.x-dev» 7.x-2.5
Category:Feature request» Support request
Issue summary:View changes
Status:Closed (fixed)» Active

Could it be that this option is back undone in the latest 7.x-2.5 version?

I tried to apply the patch to that version (there's no longer a 2.x-dev version), but I got WSOD'd.

I have a multilevel menu, but it seems that only the toplevel menu items are sorted properly in the view, not their sub-items.

Must add that the Weight module was enabled after all the nodes (and their menu-items) were created, does that make a difference?

knalstaaf’s picture

Status:Active» Closed (fixed)

Must add that the Weight module was enabled after all the nodes (and their menu-items) were created, does that make a difference?

Apparently it does. So you need to order your items once again in the menu configuration (e.g.: admin/structure/menu/manage/main-menu). So actually you just have to shift each menu-item one position and back, so it eventually looks like it has never been touched (be it that they have an asterisk behind their title now), but it does set the menu weights in the background this time.

(Using Menu Node Views, no Weight module seemingly O_o)