Posted by esllou on July 4, 2009 at 1:20pm
Jump to:
| Project: | Views |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | merlinofchaos |
| Status: | active |
Issue Summary
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
#1
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.
#2
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,
),
#3
try changing that manually and re-importing it. Does it now behave as you expect?
#4
Hi
I have same problem. Reimporting after manual change to reduce value makes no difference.
Thanks
#5
I am also having this issue with content types exposed. It would be great to know if anyone is working on this issue.
#6
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.
#7
I also am experiencing this behavior. Views 6.x-2.6 w/ Drupal 6.13
#8
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
#9
How do I "limit list to selected items" for Drupal 5?
#10
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.
#11
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.
#12
subscribe
1 hour ago everything was working fine. I did absolutely nothing.
what the hell ?
#13
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.
#14
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?
#15
I'll take a look at this and see if I can figure out what it's about.
#16
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)
#17
Thanks richardathome, this was a work around for me using D6.17, Views 6.x-2.11.
#18
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.
#19
Seeing this on D7 too.