it-swarm-eu.dev

Zobrazení 3 nerozpoznává deklarovaný popisovač. Proč ne?

V modulech/addressfield/addressfield.module mám:

/**
 * Implements hook_views_api().
 */
function addressfield_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'addressfield') . '/views',
  );
}

a

/**
*  Implements hook_field_views_data_alter
* 
* @param mixed $result
* @param mixed $field
*/
function addressfield_field_views_data_alter (&$result, $field) {
  if (array_key_exists('field_data_field_address', $result)) {
    $result['field_data_field_address']['field_address_country'] += array(
      'title' => t('Country'),
      'help' => t('The Country name of the field'),
      'field' => array(
        'handler' => 'addressfield_views_handler_field_country',
        'click sortable' => TRUE,
      ),
    );
  }
}

V modulech/addressfield/views/addressfield.views.inc:

/**
 * Implementation of hook_views_handlers().
 */
function addressfield_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'addressfield') . '/views',
    ),
    'handlers' => array(
      'addressfield_views_handler_field_country' => array(
        'parent' => 'views_handler_field',
      ),
    ),
  );
}

Tento soubor se nespustí v debuggeru, když vymažu mezipaměť. Tomu nerozumím.

Obsluha je v modulech/addressfield/views/addressfield_views_handler_field_country.inc, které jsem vzal z lokalizačního modulu:

/**
 * @file
 * Country field handler.
 */

class addressfield_views_handler_field_country extends views_handler_field {

  function option_definition() {
    $options = parent::option_definition();
    $options['style'] = array('default' => 'name');
    return $options;
  }

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['style'] = array(
      '#title' => t('Display style'),
      '#type' => 'select',
      '#options' => array('name' => t('Country name'), 'code' => t('Country code')),
      '#default_value' => $this->options['style'],
    );
  }

  function render($values) {
      return check_plain(strtoupper($values->{$this->field_alias}));
  }
}

Jakékoli rady, jak to do práce, by bylo užitečné. Děkuji.

12
Adam S

Kterou základní verzi? V Drupal 7, hook_views_handlers () je pryč, přidejte soubory místo toho do svého .info souboru.

files[]=views/addressfield_views_handler_field_country.inc
22
Berdir