We are embedding a view through code and are having trouble to pass data along in ajax. We need to pass a complex array of data, which we are using in hook_views_pre_view() to dynamically add/alter filter options, pagers etc.

After switching the view to ajax, we were having some troubles passing our data to the view. The only thing we can use for this at the moment are the views arguments (and since these can only be a string, we are adding a lot of them).

To support this I see 2 options:
- Quick & Dirty: We can use the arguments array and json_encode / json_decode it to allow an array to be passed. As long as you don't use this it will work as usual.
- We can add a extra ajax_data property to the view which will be passed in ajax requests with json_encode / json_decode.

Is this something you would consider supporting? Passing data via ajax could be very usefull. If this is something that could be added, I will write a patch for this.

If there is a way to already do this, or another way to support a feature like this, please let me know.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

seanB’s picture

Status: Active » Needs review
FileSize
3.42 KB

Attached is a patch to add this functionality. Please let me know if this could be added.

Status: Needs review » Needs work

The last submitted patch, 1: views-ajax_pass_data_to_view-2353157-1.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: views-ajax_pass_data_to_view-2353157-1.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: views-ajax_pass_data_to_view-2353157-1.patch, failed testing.