1

I'm keeping a Unix timestamp in a text field. In Views, I want to convert it to a readable date. This is a commerce view, and the field is a custom field of an order.

Can I use hook_field_formatter_view() to use as my own formatter? Something like:

function mymod_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

    if ($entity_type == 'commerce_order') {
          // figure out field type and instance
    }

}

If that is a way to do it, I want to look at the params through Devel, so what can I return until I'm ready to operate on them?

2

You can use hook_views_pre_render to change the output of your field..

This hook is called right before the render process. The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.

Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after. Altering the content can be achieved by editing the items of $view->result.

function MYMODULE_views_pre_render(&$view) {

   if ($view->name=='viewyouarelookingfor') {

      // do whatever you want

   }

 }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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