1. Create view by content type. Many content types present on site.

2. Expose "Content type" filter.

3. User selects content type, presses "submit"...only those content types are returned. All OK.

4. Edit view, alter "Is one of" only to Video, Audio, Image. Choose "limit list to selected items".

5. Exposed filter contains only those three content types but on loading the view page, all content types returned.

Here is a very simple view to duplicate this behaviour:

$view = new view;
$view->name = 'viewtest';
$view->description = 'test';
$view->tag = 'test';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'type' => array(
    'label' => 'Type',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'totalcount' => array(
    'id' => 'totalcount',
    'table' => 'node_counter',
    'field' => 'totalcount',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'image' => 'image',
      'audio' => 'audio',
      'video' => 'video',
    ),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'type_op',
      'identifier' => 'type',
      'label' => 'Node: Type',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 1,
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 30);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 1,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'type' => 'type',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'type' => array(
      'sortable' => 1,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'test-view');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

Comments

gettysburger’s picture

I am having the same problem, with an exposed filter is showing all roles, although I have it set to limit the roles shown. This view has been working fine for about a year. I upgraded from version 6.x-2.2 to 6.x-2.6 just today and that broke it.

gettysburger’s picture

I did some investigation and when I export my view I see that reduce is set to "0", even though I have "Limit list to selected items" checked. What could cause that?

'value_1' => array(
'operator' => 'in',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'value_1_op',
'identifier' => 'value_1',
'label' => 'Department',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),

esllou’s picture

try changing that manually and re-importing it. Does it now behave as you expect?

limehouse’s picture

Hi

I have same problem. Reimporting after manual change to reduce value makes no difference.

Thanks

moondancerjen’s picture

I am also having this issue with content types exposed. It would be great to know if anyone is working on this issue.

gettysburger’s picture

I had Acquia support look at this and their Views guru said it is a bug and that she would be putting up her findings.

fmesco’s picture

I also am experiencing this behavior. Views 6.x-2.6 w/ Drupal 6.13

Wappie08’s picture

Same with me, though it worked some day earlier; started experiencing errors when working with the following options today:

- more displays in the view either overriding or not
- adding a tabbed menu from two or three displays
- adding Attachment display

Greetings

cyoong87’s picture

Version:6.x-2.6» 5.x-1.6
Category:bug» support

How do I "limit list to selected items" for Drupal 5?

midkemia’s picture

Version:5.x-1.6» 6.x-2.6
Category:support» bug

Restoring version and category.
Please raise as a new issue if needed, and for the correct version rather than downgrade the version of an existing issue.

dawehner’s picture

This could work in theory

diff --git handlers/views_handler_filter_in_operator.inc handlers/views_handler_filter_in_operator.inc
index d7b6e3d..ddcee4c 100644
--- handlers/views_handler_filter_in_operator.inc
+++ handlers/views_handler_filter_in_operator.inc
@@ -328,6 +328,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
   }

   function query() {
+    dsm(123);
     $info = $this->operators();
     if (!empty($info[$this->operator]['method'])) {
       $this->{$info[$this->operator]['method']}();
@@ -336,7 +337,14 @@ class views_handler_filter_in_operator extends views_handler_filter {

   function op_simple() {
     if (empty($this->value)) {
-      return;
+      // If the user selected "Limit list to selected items",
+      // the view should display just this selected items, so add a filters
+      if (!empty($this->options['expose']['reduce'])) {
+        $this->value = array_keys($this->reduce_value_options());
+      }
+      else {
+        return;
+      }
     }
     $this->ensure_my_table();

But the problem is that query is not runned at all here.

benone’s picture

subscribe

1 hour ago everything was working fine. I did absolutely nothing.

what the hell ?

Glenmoore’s picture

subscribe

this issue seems to have gone quiet but I'm still having the problem with D6.16 and Views 6.x-2.11 or 6.x-3.0-alpha3.
Tried the patch in #11 but no luck.

kbk’s picture

Same problem. This is #721358: unable to select "Limit list to selected items" indicates a patch has been applied for 6.x-3.x. Can this be ported?

merlinofchaos’s picture

Assigned:Unassigned» merlinofchaos

I'll take a look at this and see if I can figure out what it's about.

richardathome’s picture

Here's a fix:

Create a second (non-exposed) Node: Type filter with the same list of 'is one of' node types selected

Resultant query looks like this (pseudocode):

With [Any] Selected:

SELECT node.*
FROM node
WHERE node.type IN ('foo', 'bar', 'baz')

With Type 'foo' selected:

SELECT node.*
FROM node
WHERE node.type IN ('foo', 'bar', 'baz')
AND node.type = 'foo';

Hope this helps (and I've explained it clearly enough :-S)

eddie_c’s picture

Thanks richardathome, this was a work around for me using D6.17, Views 6.x-2.11.

Glenmoore’s picture

Forgive me if I'm mistaken but I think richardathome's work around solves eddie_c's initial problem of having all content types returned (even though "limit list to selected items" is selected) but it doesnt solve the problem that this issue morphed into ie the one that was highlighted in #1 by gettysburger.
Unless I'm mistaken his issue was that selecting the "limit list to selected items" had no effect on the items actually listed ie all items are still listed. This is certainly still my problem.

joachim’s picture

Version:6.x-2.6» 7.x-3.x-dev
Component:User interface» Code

Seeing this on D7 too.

pjcdawkins’s picture

Also seeing this on D7 with an exposed filter. "Limit list to selected items" on a taxonomy term reference field results in the exposed filter rendering correctly, but the view contains nodes which don't match the list.

pjcdawkins’s picture

... although, come to think of it, it is a problem trivially overcome by just adding a new, hidden filter to strip out the items not in the list. Perhaps that is the design, although it is a bit of a WTF.

likewhoa’s picture

Why is this being ignored for so long? doing what #21 suggest is what I ended up doing before coming here but that is definitively not by-design.

jucallme’s picture

As a work around i have found that simply duplicating the exposed filter and NOT exposing it and then limiting the terms once again on that removes those that are added by the all option, hope this helps some one else.

NecroHill’s picture

#23 doesn't work in my case

jenlampton’s picture

Still a problem in the 7.x version, but suggested work-around in #16 and #23 works for me.

zhuber’s picture

#23 does not work well with large queries. I have an exposed filter with about 50 acceptable values, when I attempt to create a secondary filter with the same values I actually get a MySQL error since I am joining to many tables. Ultimately, this checkbox should work with the intended functionality and not require a work around.

ptmkenny’s picture

I'm also having this problem with taxonomy terms as described here: http://drupal.stackexchange.com/a/32409/5147

DerekAhmedzai’s picture

The workaround in #23 works for me too.

wickwood’s picture

The hack in #16 which is restated in #23, works for me too. Hope this can be fixed, because it drove me nuts for hours.

miccelito’s picture

Using Views 7.x-3.7

Added am exposed filter Content:[Vocabulary] dropdown list with terms.
The 'Limit list to selected items' feature looks a bit buggy but it works howsoever but only if doing it in following order:
1. Select terms/options in the list
2. Thereafter check 'Limit list to selected items' checkbox
3. Apply display
Once you have selected (marked) the options and checked 'Limit list to selected items' checkbox, you can't select more options since otherwise the already selected options will get lost.

ranavaibhav’s picture

This is still occurring...

jonbim’s picture

#23 Works for me too. I think it's true as @zhuber said that the memory issue relates to complexity of the SQL in your view - the hack works fine on fairly large data sets however.

justb3a’s picture

The problem is in file modules ▸ views ▸ modules ▸ taxonomy ▸ views_handler_filter_term_node_tid.inc on line 168.

<?php
 
if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
   
$default_value = array();
  }
?>

Activating the ``required`` checkbox solves the issue for me.