dsfdsf21321 2010-08-06 06:59
浏览 11
已采纳

Drupal暴露视图

is there a way to not display any results initially until the form has been submitted?

Also, I cant see where I can override the exposed form

  • 写回答

5条回答 默认 最新

  • dtcwehta624485 2010-08-06 08:56
    关注

    As @googletorp mentioned, you can override the expose form using hook_form_alter(): check out a couple examples in other questions to get an idea of how it works:

    To display a blank form unless the user fills out the exposed form, you can use hook_views_query_alter() in a custom module:

    function test_views_query_alter(&$view, &$query) {
      $filter_set = FALSE;
    
      foreach ($view->filter as $filter) {
        // Check if we've found a filter identifier that is set
        if ($filter->options['exposed'] && array_key_exists($filter->options['expose']['identifier'], $_GET)) {
          $filter_set = TRUE;
          break;
        }
      }
    
      // If the filter isn't set, add a WHERE clause to the query that
      // cannot be TRUE. This ensures the view returns no results.
      if (!$filter_set) {
        $query->add_where(0, 'FALSE');
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大