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
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.
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
-
Why
hook_entity_property_info_alter()
instead ofhook_entity_property_info()
? I just implementedhook_entity_property_info()
for the 'created' property but the Views configuration page reports the error messageBroken/missing handler
. I don't know how I'm supposed to define this handler.– okey_onJul 21, 2017 at 20:03 -
Wow
hook_entity_property_info_alter
worked. I'd think thathook_entity_property_info
would work as well but apparently it didn't. Or maybe I did not implement it correctly?– okey_onJul 23, 2017 at 5:44