简体   繁体   English

Drupal 8,两个上下文过滤器,如何仅使用第二个?

[英]Drupal 8, two contextual filters, how to only use the second one?

I have two taxonomies: "colours" and "shapes". 我有两个分类法:“颜色”和“形状”。 I have a content type called "object" that has a field for "colour", and a field for "shape". 我有一个称为“对象”的内容类型,其中有一个“颜色”字段和一个“形状”字段。

Then I have a simple view that lists content of type "object", and that has two contextual filters: one for "colour", and one for "shape". 然后,我有一个简单的视图,其中列出了“对象”类型的内容,并且具有两个上下文过滤器:一个用于“颜色”,一个用于“形状”。

If I go to /my-view/1, I get a list of all objects that are of colour "blue" (term id 1) 如果我转到/ my-view / 1,则会得到所有颜色为“蓝色”(术语ID为1)的对象的列表。

if I go to /my-view/1/5, I get a list of all the objects that are of colour "blue" and of shape "circle". 如果我转到/ my-view / 1/5,则会得到所有颜色为“蓝色”且形状为“圆形”的对象的列表。

So far so good. 到现在为止还挺好。

What however if I want to list all objects of shape "circle"? 但是,如果我想列出所有形状为“圆形”的对象怎么办? In other words, I only want to specify the second contextual filter. 换句话说,我只想指定第二个上下文过滤器。 Obviously /my-view//5 doesn't work, so how can that be done? 显然/ my-view // 5不起作用,那怎么办呢?

(Note: I'm actually trying to do that programmatically by calling views_get_view_result("objects", "default", 1, 5). In the same way I can call views_get_view_result("objects", "default", 1), but I can't figure out how to call it with only the second contextual filter). (注意:实际上,我实际上是通过调用views_get_view_result(“ objects”,“ default”,1,5)以编程方式做到这一点。我可以通过相同的方式调用views_get_view_result(“ objects”,“ default”,1),但是我不知道如何仅使用第二个上下文过滤器调用它。

(Note2: I'm using Drupal 8, but it's actually the same with Drupal 7) (注2:我使用的是Drupal 8,但实际上与Drupal 7相同)

Never mind, even though I looked for the answer for a couple of days, I found it 5 minutes after posting... 没关系,即使我找了几天的答案,我在发布5分钟后还是找到了答案...

I need to specify an "exception" in the contextual filter - for example "all". 我需要在上下文过滤器中指定一个“例外”,例如“ all”。 Then I can go to /my-view/all/5, or call views_get_view_result("objects", "default", "all", 1) 然后,我可以转到/ my-view / all / 5,或调用views_get_view_result(“ objects”,“ default”,“ all”,1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Drupal视图中添加多个上下文过滤器? - How to add more than one contextual filters in drupal view? 我们如何使用两个上下文过滤器,因为当我使用两个上下文过滤器时,它仅从第一个过滤器过滤第二个上下文过滤器被忽略 - How do we use two contextual filter because when i use two contextual filter it only filter from first filter second contextual filter is ignored Drupal 7视图上下文过滤器 - Drupal 7 Views Contextual Filters Drupal 7视图,如果没有定义第二个过滤器,则2个上下文过滤器不起作用 - Drupal 7 Views with 2 contextual filters not working if second filter not defined Drupal 7查看上下文过滤器或逻辑 - Drupal 7 Views contextual filters OR logic 如何在Drupal 7中以URL为标题的视图(上下文过滤器)中获得结果 - How to get results in Views (Contextual Filters) regarded titles in URL in Drupal 7 Drupal视图-使用第一个参数来计算第二个上下文过滤器参数 - Drupal views - Use first argument to calculate second contextual filter argument 在drupal中使用上下文过滤器时,如何防止将页面上下文过滤器附加到页面url? - How to prevent the page contextual filter to be appended to the page url when using contextual filters in drupal? Drupal 7- 从外部表单传递上下文过滤器 - Drupal 7- Passing contextual filters from external form Drupal 7:第二个URL参数的上下文过滤器(分类术语) - Drupal 7: Contextual Filter for Second URL Argument (taxonomy term)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM