Question

I have a problem with the API Views, I look for a solution for more than two weeks. I found tutoriels on the Internet but not way to show this filter. I have or errors SQL or no error message as with this code but it does not display in the list of filters. Could you help me? Thank you in advance for your answers.

/**
 * 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;
}

Thank !

Was it helpful?

Solution

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'
    )
  );
}

Try this way its work for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top