Posted by plousia on October 28, 2010 at 3:38pm
4 followers
| Project: | Nodequeue |
| Version: | 6.x-2.10 |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I know this issue has come up a few times, but I'm wondering if it's possible to add an option to an individual nodequeue's settings to limit the nodes which can be added to published content. The site I'm working on only uses nodequeues to display published nodes, but it's possible to add unpublished ones, which then simply don't display on the site. An option like this would significantly reduce confusion for the users, but still allow an individual queue to contain unpublished nodes if necessary.
Comments
#1
This sounds like a reasonable request. The problem is that Nodequeue settings are all stored in a DB table {nodequeue_queue} so adding this feature and using the current settings paradigm for a queue would require adding a column to the nodequeue table as well as the standard Form API work and work on the autocomplete query to restrict by published status.
That being said, I think it's worthwhile and I will give it a try.
#2
Ok I've put together a quick and dirty patch to get this up and running. Please review and maybe try on your site.
#3
Thanks so much for working on this. Unfortunately not working as expected. I check the "Limit to nodes that have published status" option and submit, but when I go back to the nodequeue settings page the option is not selected, and I'm still able to add unpublished nodes.
Also, I notice that this setting applies to the autocomplete field; it would be nice if on the nodequeue tab on an individual node the option to add to queue would be removed for unpublished nodes and, if set, the add/remove nodequeue links on each node wouldn't display on unpublished nodes. Not sure how much work this is, I definitely appreciate the time you've put into it. I'd love to be able to do this myself but unfortunately I'm not a coder.
#4
You will need to run a module update in order to add a field to the nodequeue_queue table with this patch. Not sure if you did that...
The option to not show the add to queue on nodequeue tab on node pages, well then you'd have to check the unpublished/published option for all possible nodequeues since the setting is per nodequeue?
#5
Yup, ran update and everything. The other problem I forgot to mention is that this patch keeps the add nodequeue form from saving, so with it applied, it's not possible to create a new nodequeue at all.
#6
Hey guys,
Had a look at this as it's rather useful to have. Normally we just modify our views to output published only and this is fine but the client requires the queue to filter when adding so the patch is perfect for what we need.
I've rerolled it (in the old skool method - I'm not git-ed up yet) so find attached.
It is working for 6.x-2.10 as I've been hidden away on a project and have just seen there is a 2.11 release out, so when I update to that I'll try making another patch if need be.
I think the issue plousia got was that the hook_update_n was for 6007 and I've moved it to 6008 (which might conflict with 2.11) and it added the field to the DB as expected.
Let me know what you think.
Thanks,
luke
#7
The last submitted patch, nodequeue-published-955826.patch, failed testing.
#8
There are two other ways that this can be done with both requiring custom code. The stock autocomplete query in nodequeue is passed through db_rewrite_sql() so in theory you can implement this hook and add the published constraint. Here is an example that we did for the same purposes on the CCK nodereference autocomplete in d6:
if ($primary_field == 'nid' && $primary_table == 'n') {// This is the query that you see with nodereference autocomplete so trying to match it.
$target_query = "SELECT n.nid, n.title AS node_title, n.type AS node_type FROM {node} n WHERE (n.type = '%s') AND (n.title LIKE '%%%s%%') ORDER BY n.title, n.type";
if ($query == $target_query) {
return array('where' => 'status = 1');
}
}
Furthermore in nodequeue.module in nodequeue_api_autocomplete() there does appear to be the ability to implement your own autocomplete callback per nodequeue:
// Call to the API.
$function = $queue->owner ."_nodequeue_autocomplete";
if (function_exists($function)) {
return $function($queue, $subqueue, $string, $where, $where_args);
}
else {
// Disable language selection temporarily, enable it again later.
if (module_exists('i18n')) {
i18n_selection_mode('off');
}
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.tnid FROM {node} n WHERE " . $where . " ORDER BY n.title ASC"), $where_args, 0, variable_get('nodequeue_autocomplete_limit', 10));
if (module_exists('i18n')) {
i18n_selection_mode('reset');
}
while ($node = db_fetch_object($result)) {
$id = nodequeue_get_content_id($queue, $node);
$matches[$id] = check_plain($node->title) . " [nid: $id]";
}
}
So if a given nodequeue had owner of 'mymodule' then you should be able to implement an autocomplete callback:
function mymodule_nodequeue_autocomplete($queue, $subqueue, $string, $where, $where_args);