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 was going crazy because the Nodequeue wasn't displaying loading all nodes that I wanted it to load from the queue. After about three hours of debugging, I discovered that it was only loading the published nodes from the queue.
Filtering out the unpublished nodes should be handled by VIews, or something else. Here's a patch that hits up nodequeue_load_nodes and nodequeue_load_titles.
Comment | File | Size | Author |
---|---|---|---|
unpublished.patch | 1.45 KB | RobLoach | |
Comments
Comment #1
RobLoachComment #2
merlinofchaos CreditAttribution: merlinofchaos commentedYou'd be surprised how many people were upset when this function *didn't* filter out unpublished nodes. I think I'm going to suggest that if you want unpublished nodes, you probably need to use a different way of getting at them. Probably use a view with embed?
Comment #3
RobLoachI guess that makes sense. What if we appended a $published parameter to the end as an option to filter out the unpublished nodes (defaults to TRUE)? This is where when I wish we had Drupal 7's awesome PDO stuff for conditional WHERE statements.
Comment #4
ezra-g CreditAttribution: ezra-g commented[edit - return the *unpublished* nodes by default]
We should have such a parameter and I would even lean towards making it return the unpublished nodes by default. There's no reason we should assume everyone is using Nodequeue for published nodes, since a queue for site admins could easily contain unpublished material. Also, Nodequeue is all about creating arbitrarily ordered groups of specific nodes, so it's not unreasonable to assume that people want all the nodes in the queue when they ask for nodes in the queue.
Comment #5
ezra-g CreditAttribution: ezra-g commentedI added a published_only parameter to these functions that defaults to FALSE, so that developers can choose which query they want. This is committed.
Thanks!
Comment #6
irakli CreditAttribution: irakli commentedI am getting "Restricted Node - NID: 106" error, for no good reason, when trying to add a new node, with the latest release of nodequeue.
I suspect it may be related to this change, because downgraded to the previous version of nodequeue, the problem is gone.
Comment #7
RobLoachWhat if we default $published_only to TRUE. So, by default it only shows published nodes. But if in the API you want to change that, you can.
Comment #8
ezra-g CreditAttribution: ezra-g commentedThat seems like a safer way of doing it. If you submit a patch, my next followup on this issue will be more timely than this one.
Comment #9
ezra-g CreditAttribution: ezra-g commentedHmm, it seems like published_only already defaults to true. Marking as fixed.