Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure if this a problem with the Weights Module, the Views Module, or my setup, but if I apply any sort of Weight filtering to a view, it returns no content.
I've added weight fields and tried all sorts of sorting options (weight, sticky) but can't get the weight filtering to work.
Any help would be appreciated.
Thanks!
Justinian
Comments
Comment #1
Summit CreditAttribution: Summit commentedSubscribing, same issue.
greetings, Martijn
Comment #2
mikesir87 CreditAttribution: mikesir87 commentedI'm having the same issue. It appears to work fine when the content is across the same content type, but messes up when the view displays different content types. Any one else notice this too?
Comment #3
Moophz CreditAttribution: Moophz commentedI didn't face yet the part where having several node types.
In the other hand, if you are using 'table' for 'views style', sorting the nodes is managed from the 'table' style settings by choosing with fields should implement the order.
My Solution is:
1-Add the field 'weight:weight' to the view fields
2-Exclude the field from display
3-Go to styles, click on table then click settings
4-Choose the field 'Weight'
5-Make sure that the default sort order is 'Descending'
6-Update then Save
Comment #4
vishun CreditAttribution: vishun commentedI am having the same issue and am using -1 for nodes that should bubble to the top. At first I had a feeling that the issue may somehow be related to negative integers, but it appears that positives integers also don't work. I'm no views expert, but I'm having a hard time locating the filter implementation of this module.
Just looked a little further and it appears that in weight.views.inc line 31 that the filter callback for weight is set as views_handler_filter_numeric where the field handler is set to a local definition of weight_handler_field_sticky and the sort handler is set to a local definition of weight_handler_sort. I'm guessing weight might need some special consideration for its filter, I'm going to look into resolving this.
Comment #5
vishun CreditAttribution: vishun commentedI'm somewhat in the middle of a local filter handler implementation and just noticed the likely problem is the value of the filter being used in the views UI. It appears that the expected value needs to match that of the database value, which is not the same value used for the actual weight. For instance, the default database value of nodes that have weight enabled on the content-type but do not have an actual weight is -100, while a node with the literal weight of -1 has a database value of -99.
So, in theory, to show only nodes with the weight of -1 through -20 you could enter something on the filter like is between min -99 max -80. Since -80 is closer to 0 and therefore is greater than -99, you would similarly do something like: is greater than -100 or is greater than or equal to -99.
I have confirmed this functionality and should be able to account for it on the filter handler.
Comment #6
rickmanelius CreditAttribution: rickmanelius commentedHey Vishun.
Is this something that has been committed to either the weight or views projects? I'm having the exact same problem (negative weights) and it's really mucking up my clients workflow! Any insight would be helpful.
Comment #7
vishun CreditAttribution: vishun commentedI am not a maintainer of this module but I'm guessing nothing regarding this has been committed to the Weight module. I/we would likely first need to finish and submit a patch for review by the community. For now you can use the previously described method of specification, like for -1 through -20, use -99 through -80.
Comment #8
davisbenThis has been fixed and committed to 6.x-1.x and 7.x-1.x.
Comment #9
vishun CreditAttribution: vishun commentedAwesome! Thank you so much 10oclock.