drupal 7中每个标签的Common Exposed过滤器

时间:2015-04-29 06:00:49

标签: drupal-7 drupal-exposed-filter

我有不同的字段并显示在不同的块中,并希望将曝光的滤镜应用于所有,但我的问题是它为每个不同的块显示不同的曝光过滤器。我想让每个街区都很常见。

以下是步骤

  1. 我为每个按钮显示了5个块。
  2. 为每个块添加了语言的公开过滤器。
  3. 现在每个块显示其不同的暴露过滤器。 但是我希望暴露的过滤器应该显示在按钮上方,并且应该适用于每个块显示。附上此问题的截图。

    enter image description here

    我安装了Session error,但是提供了{{1}}。

2 个答案:

答案 0 :(得分:0)

我正要建议使用Views Global Filter。

另一种方法是在从url拉出的所有块上设置一个上下文过滤器,这样它们每个都会拉出相同的值。 这是视图问题队列中的一个活动问题,有一些人使其工作: https://www.drupal.org/node/1587894 注释#6有一些简单的代码,这将在这里应用 https://www.drupal.org/node/1871388

答案 1 :(得分:0)

3天后,我甚至没有通过编程方式找到解决方案。

那么我最后一个选择(在我看来,呵呵)是,

  1. 我只获取一个块中的所有字段,而不是为不同的选项卡或按钮创建不同的块。
  2. 使用了Better Exposed Filters的说明,其中我将按钮/标签UI HTML粘贴为其中。
  3. 现在,在更改语言时,将根据所选语言提取所有字段。但在这种情况下,我的活动标签/按钮会失去活力。
  4. 现在,我需要获取最后一个活动标签/ buuton,以便我可以在过滤我的语言后再次单击它以获取活动标签。
  5. 以下是js file所需的代码段。

    // Active target element to make the tab/button active after 
    // ajax responds in filter
    var activeTargetElement;
    Drupal.behaviors.events = {
        attach: function (context, settings) {
            $('#views-exposed-form-MY_VIEW_MACHINE_NAME-BLOCK_NAME', context).ajaxStart(function () {
                // my tabs/button are active on the basis of data-target attribute,
                // so need to memorise which tab/button is active before fitering any language 
                activeTargetElement = $('#MY_TABS li.active a').data('target');
            }).ajaxSuccess(function () {
                // if any target is memorised, then simply click it or trigger a click event for it
                if($('[data-target="'+activeTargetElement+'"]').length){
                    $('[data-target="'+activeTargetElement+'"]').click();
                }
            });
        }
    };