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

Summit’s picture

Subscribing, same issue.
greetings, Martijn

mikesir87’s picture

I'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?

Moophz’s picture

I 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

vishun’s picture

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

vishun’s picture

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

rickmanelius’s picture

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

vishun’s picture

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

davisben’s picture

Status: Active » Fixed

This has been fixed and committed to 6.x-1.x and 7.x-1.x.

vishun’s picture

Awesome! Thank you so much 10oclock.

Status: Fixed » Closed (fixed)

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