0

I created a custom Entity with one of the properties named 'created' and set with the Drupal REQUEST_TIME in seconds. I want to display this property using the Views module as a formatted Date/Time field. The Date/Time format option is not offered on the Views field settings dialogue.

1 Answer 1

1

Implement hook_entity_property_info_alter() to describe your custom entity type's properties to the Entity API module, which will then automatically create Views integration based on the types of fields in your database table.

http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.api.php/function/hook_entity_property_info_alter/7

An example of this can be found in the Log module, which has three timestamps (timestamp, created, and changed). It gives each of these a "type" of "date" in the entity property info, which automatically makes them visible to Views as date fields. http://cgit.drupalcode.org/log/tree/log.module#n242

2
  • Why hook_entity_property_info_alter() instead of hook_entity_property_info()? I just implemented hook_entity_property_info() for the 'created' property but the Views configuration page reports the error message Broken/missing handler. I don't know how I'm supposed to define this handler.
    – okey_on
    Jul 21, 2017 at 20:03
  • Wow hook_entity_property_info_alter worked. I'd think that hook_entity_property_info would work as well but apparently it didn't. Or maybe I did not implement it correctly?
    – okey_on
    Jul 23, 2017 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.