【问题标题】:How to pass an array to a view as Contextual Filter如何将数组作为上下文过滤器传递给视图
【发布时间】:2014-07-23 05:57:32
【问题描述】:

我是 Drupal 的新手。我目前正在使用drupal 7 开发一个电子商务网站。我想知道如何将一组nid 传递给views_embed_view('view_name','display_name',contextual filter) 上下文过滤器。这是我的示例代码-

foreach($result as $record)
    {
        $querystring .= "+";
        $querystring .= $record->nid;       
    }
    $querystring = ltrim($querystring, '+');
    views_embed_view('tours_listings', 'page_2',$querystring);

【问题讨论】:

    标签: view drupal-7 drupal-contextual-filters


    【解决方案1】:

    您可以通过以下方式添加完成此操作: 检查

    在查看上下文设置页面上允许多个值。

    如果选中,用户可以以 1+2+3 的形式输入多个值。到期的 到它需要的 JOIN 数量,并且将被视为 OR 用这个过滤器。

    然后代替上面的代码: $recordIds = array(); foreach($result as $record) { $recordIds[] = $record->nid; } $querystring = implode('+', $recordIds); //Do not forget to print this out. print views_embed_view('tours_listings', 'page_2', $querystring);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多