I've run into an issue similar to this one: http://drupal.org/node/193146 where I'm trying to create a filter to select a position within a single queue (for instance, position 2 in qid=1, as opposed to position 2 in any queue). Here is my view's filter code:

  $view->filter = array (
    array (
      'tablename' => 'nodequeue_nodes',
      'field' => 'position',
      'operator' => '=',
      'options' => '',
      'value' => '2',
    ),
    array (
      'tablename' => 'nodequeue_nodes',
      'field' => 'qid',
      'operator' => 'AND',
      'options' => '',
      'value' => array (
        0 => '1',
      ),
    ),
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),

But if the node is in two different queues, this will not work (i.e., the view returns two nodes), for instance nid 10756:

mysql> select * from nodequeue_nodes where qid IN (1,6) order by qid,position;
+-----+-------+----------+------------+------+
| qid | nid   | position | timestamp  | sqid |
+-----+-------+----------+------------+------+
|   1 | 10756 |        1 | 1233952387 |    1 |
|   1 | 10693 |        2 | 1233952387 |    1 |
|   1 | 10753 |        3 | 1233952387 |    1 |
|   1 | 10734 |        4 | 1233952387 |    1 |
|   1 | 10719 |        5 | 1233952387 |    1 |
|   6 | 10543 |        1 | 1237993714 |    6 |
|   6 | 10756 |        2 | 1237993714 |    6 |
|   6 | 10624 |        3 | 1237993714 |    6 |
|   6 | 10677 |        4 | 1237993714 |    6 |
|   6 | 10705 |        5 | 1237993714 |    6 |
+-----+-------+----------+------------+------+
10 rows in set (0.00 sec)

It's a very simple fix: here's a patch against 5.x-2.5:

--- nodequeue.views.inc.old     2009-03-25 15:35:02.000000000 -0400
+++ nodequeue.views.inc 2009-03-25 15:38:39.000000000 -0400
@@ -135,6 +135,13 @@
             'help' => t('Sort by the position of the node in a given queue. Use this only if, for some reason, you are filtering in such a way that you are including nodes from multiple queues; otherwise use the simpler "NodeQueue: Queue Position" filter.'),
           ),
         ),
+               "filters" => array(
+          "position" => array(
+            'name' => t("NodeQueue: Queue Position in @queue", array('@queue' => $queue->title)),
+                       'operator' => 'views_handler_operator_gtlt',
+            'help' => t('Filter by the position of the node in a given queue (as opposed to its position in any queue).'),
+          ),
+               ),
       );
     }
   }

Comments

ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for the detailed database dump :)!

If the problem is getting the same node twice, couldn't you resolve this by adding a "distinct" filter to the View?

ezra-g’s picture

Status: Postponed (maintainer needs more info) » Fixed

Marking as fixed due to lack of a response.

Status: Fixed » Closed (fixed)

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