Active
Project:
Nodequeue
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Mar 2012 at 19:38 UTC
Updated:
10 Nov 2017 at 09:53 UTC
Jump to comment: Most recent
I would like to sort nodes based on nodequeue position in a View based on a Search API index.
But
- I can't add a Nodequeue relationship in my view
- I can't add the "nodequeue position" field to my search index
Is there a way to use Nodequeue module with views based on Search API module?
Thanks
Comments
Comment #1
kevster commentedI would love to do the same thing but not sure how - this would be very useful...
Comment #2
jody lynnI needed this for a queue so I implemented it in a custom module for a specific queue. This could be expanded to work for all available queues.
Comment #3
mrharolda commented@Jody Lynn thanks for the example! I had to extend it so that items are re-indexed after the nodequeue's sorting is changed:
Comment #4
tancJust wanted to say thank you to Jody Lynn and MrHaroldA for posting that code. Made the process quite painless.
Comment #5
charginghawk commentedFor anybody stumbling across this, here's how I pulled it off most recently, based off the code above:
Comment #6
hmartens commentedThanks guys, must I add this code to a "new" module or can I add it in the template.php?
Thanks.
Comment #7
charginghawk commentedI implemented it in a custom module.
Comment #8
thirstysix commentedBut, I add "Queue Position" only in the field. Can't add a Nodequeue in the view relationship or view sort.
Comment #9
nadavoid commentedThanks for all the code samples! I've made the following updates for my use case.
1. In the config of my nodequeue, I checked "Reverse in admin view". This means that the top item in the list in the admin view will have the largest number. If there are 4 items in the queue, the top item will have position 4. This removes the need to reverse the number in the entity property callback. You can simply store $pos as it truly is.
2. I used
hook_nodequeue_update()because it's invoked after the nodequeue has been completely updated, instead ofhook_nodequeue_sort_alter()which can be invoked even if the nodequeue is not successfully saved.@satheeshkumar.six What you will need to do is in your search api configuration, add the new "queue_position" (according to the posted examples) field to the index. Then that field will be available to your view, without needing to add any relationships.
Comment #10
interdruper commentedIf you use a queue with just one subqueue, it is easier just reference the subqueue: