I want to be able to cache a json datasource view, but add addition data before the response is sent. Is there some way to do this? I have tried using a hook_views_post_render ( https://api.drupal.org/api/views/views.api.php/function/hook_views_post_... ) which exists for this purpose, but can't seem to alter the $output. Is there some other way?

Background: I have a view of books which will rarely change and common for all users. Users can bookmark their place in a book and 'like' a book. I would like to get the user's bookmarks and likes after the view has come from the cache.

Comments

anthonylindsay’s picture

Status: Active » Closed (works as designed)

hook_views_post_render isn't called because it is not being printed to a page. Drupal_json_output interrupts that.

If you want to alter it you'll have to hook in earlier (harder to do) , or separately fetch the bookmarks and deal with it client-side (a bit more overhead, but probably the solution I would choose).