Problem/Motivation
It would be awesome to be able to use the ajax features Views has built-in with the Views Content display (Context aka ctools_context
).
Proposed resolution
The attached patch adds the content type configuration to the views ajax settings (potential security issue?) and uses hook_views_ajax_data_alter()
to replace the default ajax commands by views content specific ones.
To make the output of the current Views content content type plugins usable for the ajax handling of views I needed to wrap the output in the same css classes as used in views/theme/views-view.tpl.php
. The wrapping is also used to set the Views content specific settings as mentioned above.
Since each rendered content type gets an unique identifier the approach should also work if you place e.g. the pager multiple times on the same page.
First tests look very promising.
Remaining tasks
Reviews needed & security audit needed - I don't like the fact that I had to expose the content type configuration in the JS (Drupal.settings.views.ajaxViews
) and I think it could have security implications. Better ideas very welcome :)
User interface changes
None
API changes
None
Related Issues
Views: #2035657: More flexible / defensive ajax handling.
Views Load More: #2035687: Integration with (Ctools) Views Content
Comment | File | Size | Author |
---|
Comments
Comment #0.0
das-peter CreditAttribution: das-peter commentedAdded related issue.
Comment #1
das-peter CreditAttribution: das-peter commentedJust found an issue with the current patch. Fixed that.
Comment #1.0
das-peter CreditAttribution: das-peter commentedAdded another related issue.
Comment #2
dawehnerI would really like to come up with a generic solution which sets some values on the view object and transports them via the ajax requests. We need this 100% for drupal 8 as well.
Comment #2.0
dawehnerTypos.
Comment #5
mrjmd CreditAttribution: mrjmd commentedHere's a straight re-roll to keep things moving.
Comment #6
das-peter CreditAttribution: das-peter commentedThanks for the re-roll!
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 4 year old patch in #5 does not apply to the latest ctools 7.x-1.x-dev and if still applicable needs to be rerolled.