Show datetime value in views with entity api I made a custom entity with a date field stored as datetime in mysql.

I see the proper output in my content, and all other field values in my views except the datetme value. Only the label is shown. So I believed that I have to write a getter callback because of this:


  getter callback: (optional) A callback used to retrieve the value of the property. Defaults to entity_property_verbatim_get(). It is important that your data is represented, as documented for your data type, e.g. a date has to be a timestamp. Thus if necessary, the getter callback has to do the necessary conversion. In case of an empty or not set value, the callback has to return NULL.


Question is how to use it? Apparantly I have to get a timestamp from a datetime field!???

Another one mentioned that views doesn't relate to property_info():


  Getter and Setter callbacks are used only by entity metadata wrappers, not Views.


So my code looks like this atm:

$info['pricedefault']['properties']['preis_zeitraum_von'] = array(
'label' =&gt; t('Start period'),
'description' =&gt; t('Preis Zeitraum von'),
'type' =&gt; 'date',
'schema field' =&gt; 'preis_zeitraum_von',
);


So it makes no sense to add a getter callback??? Or do I have to make my own views entity controller class?

ATM I'm very confused. Can anybody explain how to proceed?

THX in advance

maen
You won't need to define a custom getter callback for known data types with a schema field since it can use entity_property_verbatim_get as it's getter callback, which is used by default if no 'getter callback' property is set.

$properties = &amp;$info['foo']['properties'];
$properties['created'] = array(
  'label' =&gt; t('Date created'),
  'description' =&gt; t('The date the foo entity was created.'),
  'type' =&gt; 'date',
  'schema field' =&gt; 'created',
);


For maximum control, I would suggest you try describing your entity to views. Assuming you have an entity type called foo, stored in the table foo with a created field, you can:

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

  $data['foo']['table']['group']  = t('Foo entity');

  $data['foo']['table']['base'] = array(
    'field' =&gt; 'foo_id',
    'title' =&gt; t('Foo entity'),
    'help' =&gt; t('The foo entity.'),
  );
  $data['foo']['table']['entity type'] = 'foo';

  // Expose a timestamp (e.g. created date).
  $data['foo']['created'] = array(
    'title' =&gt; t('Created'),
    'help' =&gt; t('The date the foo was created.'),
    'field' =&gt; array(
      'handler' =&gt; 'views_handler_field_date',
      'click sortable' =&gt; TRUE,
    ),
    'sort' =&gt; array(
      'handler' =&gt; 'views_handler_sort_date',
    ),
    'filter' =&gt; array(
      'handler' =&gt; 'views_handler_filter_date',
    ),
  );
}


Then, you can also do things like:

// An argument handler accepting year and month
$data['created']['created_year_month'] = array(
  'title' =&gt; t('Created year + month'),
  'help' =&gt; t('In the form of YYYYMM.'),
  'argument' =&gt; array(
    'field' =&gt; 'created',
    'handler' =&gt; 'views_handler_argument_node_created_year_month',
  ),
);


For more info on integrating with views, you can install Advanced help module, and check out the included Views documentation.