[support] Entity exposed to view but 'date' type field are not present

Juraj Chlebec havran at gmail.com
Tue Jul 24 15:10:56 UTC 2012


Hi,

I have same problem as here: http://drupal.org/node/1021466#comment-4766902

Callbacks are only used by
wrappers<http://drupal.org/node/1021466#comment-4766902>
Posted by JvE <http://drupal.org/user/892998> on *July 22, 2011 at 10:18am*

Note that the "getter callback" and "setter callback" functions are
*only*used by Entity metadata wrappers.
Not by entity_load or Views and such.

You can not use these to convert a different timestamp format in a database
to a timestamp for use with the 'date' type unless you specifically create
a wrapper for each of your entity instances.

I tried to get my (int)yyyymmdd values from the database to show up in
Views as dates and mistakenly thought I could use the "getter callback" for
the transformation.
Example of when callback is and is not used:
<?php
    $entity = entity_load('myentity', array(1));
    print $entity->day; // this gives 20110721 (from the database)
    $item = entity_metadata_wrapper('myentity', $entity);
    print $item->day->value(); // this gives 1311206400 (from the "getter
callback")
?>

In Views my day shows up as "08/21/1970 - 19:18" ...
so if someone can point me in the right direction to get my "days" as
timestamps, I'm all ears.


How can i use "getter callback" to convert field from database stored as
'date' to timestamp for using for view? Or is there other way how to
achieve this goal?

Juraj

-- 
Juraj Chlebec aka Havran
http://www.svoji.sk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120724/0b3985f1/attachment.html 


More information about the support mailing list