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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ericduran’s picture

Status: Active » Needs review

Oh 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.

merlinofchaos’s picture

Hmm. I suppose the lack of context does make it very difficult. dereine, what do you think?

ericduran’s picture

ignored! Wrong patch attached.

ericduran’s picture

Same 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 :(

dawehner’s picture

Status: Needs review » Fixed

Yes hook_ajax_render_alter does miss important context, so commited this patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

skh’s picture

Title: Missing hook_ajax_data_alter » Missing hook_views_ajax_data_alter

Title confused me for a moment before looking at the patch for the proper hook name.