The WHERE clause generated by a contextual filters is always grouped with the first "and/or" group of static filters. Thus the order of the "and/or" filter-groups is significant, and re-ordering them changes the semantic of contextual filter(s) entirely—not just how it is rendered into a SQL query.

Is this a bug?

If it is a feature, might the feature change or be removed in the future? Since the GUI does not communicate this at all, is it documented anywhere?

If there are multiple contextual filters, they can not be assigned to different "and/or" groups. Is that a bug?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Well that's currently a know behaviour and would probably require to edit all argument handlers.

In general this would be solved one day by using #357082: Pull filter value from an argument? because then you can move around your filters/filters prefilled with arguments as you wish.

Feel free to document the current behaviour.


If there are multiple contextual filters, they can not be assigned to different "and/or" groups. Is that a bug?

Just to clarify this, you are right, this is not possible at the moment.

The underlying problem is that in handler/views_handler_argument.inc $this->add_where(0, ...) is done.

Bevan’s picture

Does #357082 add a UI for ordering and grouping contextual filters? That is the best place to document this behaviour.

In the meantime, where would be a good place to document the current behaviour? Or is this just duplicate?

dawehner’s picture

#357082: Pull filter value from an argument? will allow to pull filter values from arguments.

So basically you sort/or-sort the filters as before. Perhaps help/argument.html is the right place to document it.

Bevan’s picture

Title: Contextual filters added to first "and/or" static filter group » Document that contextual filters are included in the first "and/or" filter group
Status: Active » Needs review
FileSize
1.22 KB

The attached patch adds the following documentation to help/argument.html:

Grouping of contextual filters

Even though contextual filters do not appear in the "and/or" user interface for sorting and grouping regular filters, contextual filters are always added to the first group of filters. Thus the order of the groups can cause the contextual filter to have entirely different effects on the results of a view that has contextual filters. Even though differences might not be apparent through the user interface.

Multiple contextual filters are therefore always in the same "and/or" group of filters, and can not be placed in different groups. There is an effort to add this feature.

dawehner’s picture

Status: Needs review » Fixed

Thanks for clarifing this!
Commited to 7.x-3.x

Status: Fixed » Closed (fixed)

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

jackbravo’s picture

Version: 7.x-3.x-dev » 7.x-3.5
Status: Closed (fixed) » Active

I believe this is no longer the case. I created a view. Added two contextual filters and two normal filters. On the filter and/or interface I set the filters to be in just one group and separated by or. On my query this is how the filters appear (this is a term view):

WHERE (( (taxonomy_term_hierarchy.parent = '636' ) AND (field_data_field_section.field_section_tid = '636' ) )AND(( (taxonomy_term_data.vid IN  ('1')) OR (taxonomy_term_data.vid IN  ('1')) )))

(I added two taxonomy vocabulary filters just so it would be easier). So the documentation seems to be wrong.

Bevan’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Status: Active » Closed (fixed)

Please open a new issue if you think the documentation is no longer correct. You can link to this one if you like.