Posted by flbr on January 25, 2011 at 5:31pm
2 followers
Jump to:
| Project: | jCarousel |
| Version: | 6.x-2.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | block caching, jcarousel, views |
Issue Summary
Block Cache is a lifesaver for our site, but we also rely heavily on the great module jCarousel. However, when I enable block cache in a view (I use Views 2, does that matter?) that has jCarousel as presentation form, the result are vague errors ("An error occurred at /jcarousel/ajax/views. Error Description: 0: ") and non-working carousels. I have tried putting the jquery manualy at the bottom of the page, but still no luck. Is this a known issue and are there any work-arounds in the mean time?
Comments
#1
The block cache is absolutely broken in Drupal 6 and there's little that we can actually do to fix it at this point. I'd strongly recommend not using it and instead put caching on your individual views (edit the view and turn on time-based caching).
#2
Thanks for the tip. I didn't know there was another way to cache. It's not as "smart", but it'll do for now.
You say there's nothing we can do. Is it because there won't be a fix in Drupal 6 since Drupal 7 is out now?
#3
Unfortunately with time-based caching, it doesn't work with AJAX (retrieving more results on pressing "next" renders the next results in the place of the previous results).
Any work-arounds to keep using block cache with jcarousel?
#4
The problem with the block cache is that it doesn't add necessary CSS/JS to the page after the block has been cached, since it only caches the HTML content within the block and not the CSS/JS that needs to be added to the page. You can work-around this by adding the jCarousel CSS and JS when necessary through drupal_add_js() and drupal_add_css() in template.php.
#5
Thanks for you help, quicksketch.
I've managed to include the necessary css and js files on every page load. Unfortunately the carousels are not rendered. This is best described with the following differences in rendered html:
With block cache ON:
<div class="view view-fp-mijn-laatste-updates view-id-fp_mijn_laatste_updates view-display-id-block_2 view-dom-id-7">With block cache OFF (desired result):
<div class="view view-fp-mijn-laatste-updates view-id-fp_mijn_laatste_updates view-display-id-block_2 view-dom-id-7 views-processed">(notice the "views-processed" here)Another example:
With block cache ON:
<ul class="jcarousel jcarousel-view--fp-mijn-laatste-updates--block-2 jcarousel-skin-default">With block cache OFF (desired result):
<div class=" jcarousel-skin-default"><div style="position: relative; display: block;" class="jcarousel-container jcarousel-container-horizontal"><div style="overflow: hidden; position: relative;" class="jcarousel-clip jcarousel-clip-horizontal"><ul style="overflow: hidden; position: relative; top: 0pt; margin: 0pt; padding: 0pt; left: 0pt; width: 870px;" class="jcarousel jcarousel-view--fp-mijn-laatste-updates--block-2 jcarousel-list jcarousel-list-horizontal">It seems the scripts are not initialized, therefor the carousels don't get rendered correctly.
Anything you or anyone can suggest?
#6
Hm, you're right. There is JavaScript that is specific to each carousel, added both by Views and jCarousel to the page. With the block cache enabled, this information will not be added and it won't work, even if you've manually added the necessary JS/CSS files.
Something I hadn't even thought to suggest, but could you just set the "Block caching" option to "Do not cache" in the View configuration? It's the default, I'd assume that this would prevent the block cache from affecting that specific block.
#7
Yes, I could disable the caching for the jcarousel-views, but those are especially the ones I'd like to have cached.
Is there a way to add the javascript programmaticly?
#8
No, not in any practical manner.
#9
Another thought, is it possible to use http://drupal.org/project/ajax_load for this purpose?