3

I'm using views data export module to output results as csv, xls, xml and txt files

I'm using Batched export (with Segment size 100) because there are many results.

I have some fields which I want to alter their values.

I have implemented hook_views_pre_render to replace field values with ones I'm getting from webservice.

The problem that some values are correctly changed, others not

Is there a solution for that?

1

Instead of a pre-render function, I think the correct spot to modify values is actually hook_views_post_execute(). This is invoked after the query has run, but before the data has been passed to rendering.

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.

It has been a while since I've personally played with Views Data Export so I'm not 100% sure why you're seeing only some values change and not others, but I recall the rendering of the export being a little abnormal compared to the usual render process.

  • Thanks for your reply, I have tried hook_views_post_execute() but it doesn't take effect, none of the values are replaced :( – Mourad Zitouni Feb 18 '16 at 16:39
  • Shoot... I think someone will need to see a code snippet (preferably the pre_render you've implemented) to see exactly what you're attempting to do to figure out why it isn't working. – Weston Wedding Feb 18 '16 at 21:59

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.