正如标题所说,我无法弄清楚为什么“-Year”被添加到我公开的过滤器选择框的顶部。我需要做些什么才能让它消失?
答案 0 :(得分:0)
在配置日期过滤器时,在“绝对值”下拉列表中选择一年。然后将显示那一年而不是-Year。我怀疑你可以从暴露的选择框中删除-Year,除非你做了一些源代码更改/添加。
答案 1 :(得分:0)
找到了解决方案,这非常愚蠢。
我最终把它放在一个自定义模块中,最后删除标签并根据数据库中的数据设置显示的年数:
function modulename_form_views_exposed_form_alter(&$form, $form_state) {
if($form['#id'] == 'theformid') {
// Remove the label as the first element from the date select
$form['date_filter']['value']['#date_label_position'] = 'none';
// Find the minimum year from all of the published news nodes
$date = db_fetch_array(
db_query("
SELECT YEAR(MIN(d.field_date_value)) as 'min'
FROM {content_field_date} d
INNER JOIN {node} n
ON n.nid = d.nid
WHERE n.type = 'news' AND n.status = 1")
);
// Set the new year range in the filter
$new_min = date('Y') - $date['min'];
$form['date_filter']['value']['#date_year_range'] = "-$new_min:+0";
}
}