By elvis2 on
Hi,
What a great module (block cache) this is. It would even be better if we could turn this baby on, choose our cached blocks and viola! But, unfortunately, that is not the case as it now. Right now you have to retheme those blocks and for those of us who have several blocks all with differen colors, shapes, etc, that is a real pain.
Anyone know how to fix this?
Thanks
Comments
I'm confused...
... isn't a block cache just a cached block of an existing block? In order to theme the cached block, you need to theme the original block that the cache was created from, right? Because all it's doing is storing a copy of that original block so that it doesn't require a database call to display...
not exactly
The block itself is the same, but drupal will display it with a different class and id because it is generated by a different module (i.e. the block cache module), so this will break any CSS that depends on the original class or id names.
Oh...
that's... annoying...
here's what I did
1. In blockcache.module, look for the blockcache_block_view function and add the following line immediately after the call to module_invoke (i.e. after line 178 in the current version) :
2. Clear the cache.
3. Add the following code at the top of block.tpl.php :
That works for me, although it will generate invalid HTML if you put both the cached and non-cached versions of the same block on the same page. If anyone knows how to do this without either a change to the blockcache module or an additional database call, please let me know.
Hi John, this worked
Hi John, this worked beautifully. Thanks for the quick response.
By any chance do you have experience with the module boost? I am wondering if boost caches the blocks as well?
Thanks for your help!
I haven't used it yet. Will
I haven't used it yet. Will be trying it out soon though.
Boost caches the entire page
Boost caches the entire page as html to the file system. I've used it a lot, works well for the most part.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Patch available
A patch is posted at #112727: Address CSS/theme issues when caching.
The web is like usenet, but
the elephants are untrained.
Good. — Fast. — Cheap.
(Pick any two.)
Not Generic Enough?
I'm guessing the patch works for basic blocks, but when I applied it to get some Views-generated blocks to work, it resulted in the blocks being displayed without any content... so I'm guessing it's not careful enough with the module name or delta if it's not a typical block-#. I recommend John's post, which does work.
I had the same issues also,
I had the same issues also, John's post http://drupal.org/node/112330#comment-192439 worked perfectly for me also