2013-12-16 98 views
0

我有一個API視圖的問題,我尋找一個解決方案超過兩個星期。我在互聯網上找到了tutoriels,但沒有辦法顯示這個過濾器。我有或沒有錯誤的SQL或沒有錯誤信息,但是它不會顯示在過濾器列表中。你可以幫幫我嗎?預先感謝您的回答。handler_filter views drupal 7

/** 
* Implements hook_views_data(). 
*/ 
function publication_filter_views_data() { 
    $data = array(); 

    $data['field_data_field_presse_date']['table']['group'] = t('Global'); 
    $data['field_data_field_presse_date']['table']['base'] = array(
    'title' => t('Global'), 
    'field' => 'entity_id' 
); 

    $data['field_data_field_presse_date']['field_presse_date_value'] = array(
    'real field' => 'field_presse_date_value', 
    'title' => i18n_t("Filter Date (Year)"), 
    'help' => i18n_t("Filtre spécifique pour les publications"), 
    'filter' => array(
     'handler' => 'publication_filter_handler_filter', 
    ), 
); 

    $data['field_data_field_presse_date']['table']['join'] = array(
    'node' => array(
      'left_table' => 'field_data_field_presse_date', 
      'left_field' => 'entity_id', 
      'field' => 'nid' 
    ) 
); 
    return $data; 
} 

謝謝!

回答

2
function modulename_views_data() { 
    $data = array(); 
    publication_filter_views_data($data); 
return $data; 
} 


function publication_filter_views_data(&$data) { 
    $data['field_data_field_presse_date']['table']['group'] = t('Global'); 
    $data['field_data_field_presse_date']['table']['base'] = array(
    'title' => t('Global'), 
    'field' => 'entity_id' 
); 

    $data['field_data_field_presse_date']['field_presse_date_value'] = array(
    'real field' => 'field_presse_date_value', 
    'title' => i18n_t("Filter Date (Year)"), 
    'help' => i18n_t("Filtre spécifique pour les publications"), 
    'filter' => array(
     'handler' => 'publication_filter_handler_filter', 
    ), 
); 

    $data['field_data_field_presse_date']['table']['join'] = array(
    'node' => array(
      'left_table' => 'field_data_field_presse_date', 
      'left_field' => 'entity_id', 
      'field' => 'nid' 
    ) 
); 
} 

試試這種方式爲我工作。