Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
I was able to do this using a module that allows you to add PHP code as a field. I needed to use the dev version 1.x, since it adds the option to define the customfield as sortable. http://drupal.org/project/views_customfield
I added to the view the fields needed to get the voting results: term ID and node ID.
Then I added a new customfield PHP to my view with the following PHP code as value:
Select Sortable Numeric. The module version seems to work only with tables as View Style. The field will not be sortable using a sort criteria, but through the table's default sort.
Not sure this is the best or only way to do it but it works.
The solution above may work, but it shouldn't be necessary. The vud node implementation allows for sorting by votes without writing php in a custom field, the vud term module should as well. I'm not sure whether bug report of feature request is more appropriate in this case, but closing based on a workaround isn't really right.
I guess there is no a simple way to do that, mainly because "sort by term" is sorting based on N terms with M votes each, so which item should be first?
I'm closing this as work as designed, since it's out of scope IMHO.
It can always be done manually if needed, probably assuming the most voted term across items, but it's not enough generic to be on main module. BTW D6 versions are mainly on bug-fixes releases for now.
Comments
Comment #1
snecci commentedI was able to do this using a module that allows you to add PHP code as a field. I needed to use the dev version 1.x, since it adds the option to define the customfield as sortable. http://drupal.org/project/views_customfield
I added to the view the fields needed to get the voting results: term ID and node ID.
Then I added a new customfield PHP to my view with the following PHP code as value:
Select Sortable Numeric. The module version seems to work only with tables as View Style. The field will not be sortable using a sort criteria, but through the table's default sort.
Not sure this is the best or only way to do it but it works.
Comment #2
PixelClever commentedThe solution above may work, but it shouldn't be necessary. The vud node implementation allows for sorting by votes without writing php in a custom field, the vud term module should as well. I'm not sure whether bug report of feature request is more appropriate in this case, but closing based on a workaround isn't really right.
Comment #3
TS79 commented(Sorting by votes on a node is only easy, if you do not change the voting tag in settings. Otherwise, you have a problem too. See #1886818: Implementation of hook_votingapi_metadata_alter for voting tags <>'vote')
Comment #4
marvil07 commentedI guess there is no a simple way to do that, mainly because "sort by term" is sorting based on N terms with M votes each, so which item should be first?
I'm closing this as work as designed, since it's out of scope IMHO.
It can always be done manually if needed, probably assuming the most voted term across items, but it's not enough generic to be on main module. BTW D6 versions are mainly on bug-fixes releases for now.