CMS Drupal Mastering Development

hook_views_post_execute() don’t work on AJAX View with exposed filters after 1st refresh

I have a View which returns 5 entities of the same type. AJAX – enabled, filters and exposed filters, all working fine.

I need to add a new result, a user – defined entity, at the top of the View results. This programmatically added row should not be affected when the exposed filters are used and should remain at the top of the View, on top of the other 5 returned results, no matter what.

I managed to add this with hook_views_post_execute() but when I use the exposed filters the View returns to its original results and my addition is lost, because AJAX is enabled on this View. hook_views_post_execute() doesn’t seem to have any effect after the initial page load.

What is a good alternative for this scenario ie alter the View in a way that’s not affected by the AJAX refresh?

Leave an answer

Your email address will not be published. Required fields are marked *