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.
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
Comment #1
gettysburger CreditAttribution: gettysburger commentedI 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.
Comment #2
gettysburger CreditAttribution: gettysburger commentedI 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,
),
Comment #3
esllou CreditAttribution: esllou commentedtry changing that manually and re-importing it. Does it now behave as you expect?
Comment #4
limehouse CreditAttribution: limehouse commentedHi
I have same problem. Reimporting after manual change to reduce value makes no difference.
Thanks
Comment #5
moondancerjen CreditAttribution: moondancerjen commentedI am also having this issue with content types exposed. It would be great to know if anyone is working on this issue.
Comment #6
gettysburger CreditAttribution: gettysburger commentedI had Acquia support look at this and their Views guru said it is a bug and that she would be putting up her findings.
Comment #7
fmesco CreditAttribution: fmesco commentedI also am experiencing this behavior. Views 6.x-2.6 w/ Drupal 6.13
Comment #8
Wappie08 CreditAttribution: Wappie08 commentedSame 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
Comment #9
cyoong87 CreditAttribution: cyoong87 commentedHow do I "limit list to selected items" for Drupal 5?
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedRestoring 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.
Comment #11
dawehnerThis could work in theory
But the problem is that query is not runned at all here.
Comment #12
benone CreditAttribution: benone commentedsubscribe
1 hour ago everything was working fine. I did absolutely nothing.
what the hell ?
Comment #13
Glenmoore CreditAttribution: Glenmoore commentedsubscribe
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.
Comment #14
kbk CreditAttribution: kbk commentedSame 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?
Comment #15
merlinofchaos CreditAttribution: merlinofchaos commentedI'll take a look at this and see if I can figure out what it's about.
Comment #16
richardathome CreditAttribution: richardathome commentedHere'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)
Comment #17
eddie_c CreditAttribution: eddie_c commentedThanks richardathome, this was a work around for me using D6.17, Views 6.x-2.11.
Comment #18
Glenmoore CreditAttribution: Glenmoore commentedForgive 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.
Comment #19
joachim CreditAttribution: joachim commentedSeeing this on D7 too.
Comment #20
pjcdawkins CreditAttribution: pjcdawkins commentedAlso 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.
Comment #21
pjcdawkins CreditAttribution: pjcdawkins commented... 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.
Comment #22
likewhoa CreditAttribution: likewhoa commentedWhy 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.
Comment #23
lathanAs 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.
Comment #24
NecroHill CreditAttribution: NecroHill commented#23 doesn't work in my case
Comment #25
jenlamptonStill a problem in the 7.x version, but suggested work-around in #16 and #23 works for me.
Comment #26
zhuber CreditAttribution: zhuber commented#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.
Comment #27
ptmkenny CreditAttribution: ptmkenny commentedI'm also having this problem with taxonomy terms as described here: http://drupal.stackexchange.com/a/32409/5147
Comment #28
DerekAhmedzai CreditAttribution: DerekAhmedzai commentedThe workaround in #23 works for me too.
Comment #29
wickwood CreditAttribution: wickwood commentedThe hack in #16 which is restated in #23, works for me too. Hope this can be fixed, because it drove me nuts for hours.
Comment #30
miccelito CreditAttribution: miccelito commentedUsing 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.
Comment #31
ranavaibhavThis is still occurring...
Comment #32
jonbim CreditAttribution: jonbim commented#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.
Comment #33
David_Rothstein CreditAttribution: David_Rothstein commentedIs this the same issue as #1309578: When using operator "Is one of" and "Limit list to selected items" - 'Any' should not ignore the selected items.? (This one is older, but that one has a patch posted for review.)
Comment #34
justb3a CreditAttribution: justb3a commentedThe problem is in file
modules ▸ views ▸ modules ▸ taxonomy ▸ views_handler_filter_term_node_tid.inc
on line 168.Activating the ``required`` checkbox solves the issue for me.
Comment #35
MrPeanut CreditAttribution: MrPeanut commentedI'm having the same issue. #23 does not work for me. When I duplicate the filter and then apply the exposed filter, I end up with no data returned. I'm not sure why — all the other filters should "pass."
My only workaround is setting the exposed filter to required and allowing multiple selections. It's not ideal because it forces the user to manually select all items (rather than "Any"), but it is working correctly.
Comment #36
ron_s CreditAttribution: ron_s commentedI saw very odd behavior when adding a second filter for user roles and using "is one of". The SQL would perform a left join that excluded whichever role was the last option in the list! As an example, Views would build the following line:
If I removed role #12 from the "is one of" option list, the role above it would be rendered as
!=
in the SQL. Makes absolutely no sense.The way I fixed this was to use the reverse operator for the second filter. Instead of using "is one of", I used "is none of". I removed the roles I didn't want included in my View, and this worked properly.
Comment #37
MrPeanut CreditAttribution: MrPeanut commented@ron_s — Ahh! You're awesome. That works for me, too. Thanks.
Comment #38
DigitalFrontiersMediaFTR, this is still an issue in D8. The workaround from #16 still applies.
Comment #39
MustangGB CreditAttribution: MustangGB commentedDrupal 8 includes Views in core, please open all issues related to Drupal 8 in the main core issue queue.
Comment #40
DigitalFrontiersMediaHas been a known bug and gone unfixed for over 9 years.
I post a comment without thinking about the fact it should have been posted against Core and I'm zinged within 10 minutes of my post! (rofl)
Comment #41
DigitalFrontiersMediaFTR, #2933474: Views "is not in" filter not working when exposed is the D8 equivalent.
Comment #42
abarpetia CreditAttribution: abarpetia as a volunteer commented#23 solved my issue. I am exposing content type filter and restricting it to only display few content types.
From my understanding, when we say "any" that means all the content and "limit list to selected items" means limit the dropdown list to only display selected items. If we want to future restrict result to only display specific content type result then we can add hidden filter like suggest in #23.
Apart from some documentation (if already not available), I don't see this issue as a bug.
There is already another issue is running so probably we should consider closing one.
Comment #43
devad CreditAttribution: devad as a volunteer commentedHi
Due to not so precise use of words in "Limit list to selected items" checkbox title and description for all drupalers who will come for the first time to this checkbox in the future - there will always be two ways how they can understand checkbox functionality.
So, I have opened separate issue as follow-up to similar D8 issue... an initiative to slightly alter checkbox description in order to make its meaning more precise and to avoid any further misunderstandings about "Limit list to selected items" checkbox proper use.
Please, feel free to join D9 Support Request: #3133906: "Limit list to selected items" checkbox - Title and description adjusting