0
正如標題所說,我無法弄清楚爲什麼「-Year」被添加到我暴露的過濾器選擇框的頂部。我需要做些什麼才能讓它消失?Drupal暴露日期過濾器:從選擇中刪除「-Year」
正如標題所說,我無法弄清楚爲什麼「-Year」被添加到我暴露的過濾器選擇框的頂部。我需要做些什麼才能讓它消失?Drupal暴露日期過濾器:從選擇中刪除「-Year」
找到了解決方案,這很愚蠢。
最後我把這個自定義模塊,並最終都移除標籤,並且還設置,顯示基於該公司在數據庫中的數據的年數:
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";
}
}
配置日期過濾器時,在「絕對值」下拉列表中選擇一年。那一年將會顯示而不是 - 年。我懷疑你是否真的可以刪除 - 從暴露的選擇框中選擇,除非你做了一些源代碼更改/添加。
的問題是,我們要當年將被選中。我終於找到了一個解決方案,我會在下面發佈。 – Karl 2010-01-13 19:25:37