Tim*_*Tim 1 php drupal views drupal-exposed-filter
有没有办法在表单提交之前不显示任何结果?
此外,我无法看到我可以覆盖暴露形式的位置
小智 5
正如@googletorp所提到的,您可以使用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');
}
}
Run Code Online (Sandbox Code Playgroud)