【发布时间】:2011-03-26 04:45:46
【问题描述】:
有没有办法在表单提交之前不显示任何结果?
另外,我看不到在哪里可以覆盖暴露的表单
【问题讨论】:
标签: php drupal views drupal-exposed-filter
有没有办法在表单提交之前不显示任何结果?
另外,我看不到在哪里可以覆盖暴露的表单
【问题讨论】:
标签: php drupal views drupal-exposed-filter
在Exposed Form Section 中,将Exposed 表单样式从basic 更改为input required
【讨论】:
如果在公开的过滤器设置中将过滤器设为可选,则视图仍应显示结果...
【讨论】:
您可以设置一个默认过滤器(在暴露的过滤器之间),比较始终为假。
【讨论】:
作为@googletorp mentioned,您可以使用hook_form_alter() 覆盖公开表单:查看其他问题中的几个示例以了解其工作原理:
要显示空白表单,除非用户填写公开的表单,您可以在自定义模块中使用hook_views_query_alter():
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');
}
}
【讨论】:
您可以在自定义模块中使用hook_form_alter 覆盖表单。
我认为视图 UI 中没有选项可以在选择之前不显示任何内容。在您的主题中,您可以检查是否有选择,并在需要时隐藏结果。
【讨论】: