Active
Project:
jCarousel
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Oct 2012 at 20:31 UTC
Updated:
31 Oct 2012 at 21:29 UTC
Jump to comment: Most recent file
I'm working on a site where we've created several "widget" modules that display content in various ways using the jCarousel module. In a few of those modules, we have to alter the view in some way before it displays. For instance, there's a case where we alter the image_style of an image in a particular field based on a large set of conditions. The jCarousel module successfully displays the modified view if AJAX isn't required. However, if items have to be dynamically inserted via AJAX, they do not retain these customizations.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | jcarousel-ajax_support_views_mods_by_other_modules-1828452.patch | 2.62 KB | austinhappel |
Comments
Comment #1
austinhappel commentedFrom what I know about Drupal and the platform I'm working on, I have 2 options: 1) set the view to not use ajax and load all items up front (not great for bandwidth usage) 2) patch jCarousel to retain view modifications done by other modules, or find another solution to this issue.
I've attached my patch to this comment, which pursues option #2 - patching the jCarousel module. If another solution is available, please let me know.
Overview of patch
Most of the time, from what I can tell, most view modifications are done to 2 arrays:
and
In all cases I've encountered, you want parity between both arrays. (I.E. if I make a change in one array, it should also be applied to the other)
What this patch does is allow module developers to append a new array to the view display containing their custom view options. The new array is jcarousel_ajax_custom_view_options.
Example:
I want custom image style for my marquee based on some conditional. I modify the view display options as I normally, would, then copy the customization to a new jcarousel_ajax_custom_view_options.
When this is done, the patched jCarousel module will check for this array. If it exists, it'll add it to the 'view_options' settings object in the carousel's javascript settings. When an item is requested over AJAX, those custom view settings are passed along in the request, parsed by `jcarousel_views_ajax()`, and merged into the view's display settings (both `display_options` and `handler->options`).
Although this solution works for me, it doesn't seem like the best solution. If you guys have any other suggestions, please let me know.