Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I'm not sure if this was done on purpose or not, but in the 6.x version of views there was a drupal_alter on the views_ajax callback which was awesome when you wanted to change the views behavior from a replace to an append for example.
While working on Drupal 7 I realized this hook doesn't exists anymore. Not sure if this was done on purpose in favor of hook_ajax_render_alter.
Again, I'm not sure if this was done on purpose but a patch is attached that adds hook_views_ajax_data_alter which takes in the ajax command that can be alter along with the view object.
Comment | File | Size | Author |
---|---|---|---|
#4 | 0001-1220498-by-ericduran-Added-Missing-hook_ajax_data_al.patch | 653 bytes | ericduran |
#3 | 0002-Issue-1212930-by-james.elliott-Changed-Convert-the-f.patch | 55.71 KB | ericduran |
views_ajax_data_alter.patch | 326 bytes | ericduran | |
Comments
Comment #1
ericduran CreditAttribution: ericduran commentedOh just incase anyone is wondering why I would prefer a views_hook instead of using hook_ajax_render_alter is that hook_ajax_render_alter doesn't have any context. You do not have the view object on that hook, and is also difficult to tell which of the commands in hook_ajax_render_alter is the views command.
This patch allows you to easily switch the replace command with a different command and or your own implementation.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedHmm. I suppose the lack of context does make it very difficult. dereine, what do you think?
Comment #3
ericduran CreditAttribution: ericduran commentedignored! Wrong patch attached.
Comment #4
ericduran CreditAttribution: ericduran commentedSame patch as the original issue. This is just a git format-patch being that i needed this on another project and git am is just easier to work with. :)
Sorry for the noise, I didn't mean to attached the wrong patch :(
Comment #5
dawehnerYes hook_ajax_render_alter does miss important context, so commited this patch.
Comment #7
skh CreditAttribution: skh commentedTitle confused me for a moment before looking at the patch for the proper hook name.