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

ubersoft’s picture

... 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...

john morahan’s picture

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.

ubersoft’s picture

that's... annoying...

john morahan’s picture

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) :

 $block['original'] = $r;

2. Clear the cache.

3. Add the following code at the top of block.tpl.php :

if ($block->module == 'blockcache') {
  $block->module = $block->original->module;
  $block->delta = $block->original->mod_delta;
}

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.

elvis2’s picture

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!

john morahan’s picture

I haven't used it yet. Will be trying it out soon though.

Jeff Burnz’s picture

Boost caches the entire page as html to the file system. I've used it a lot, works well for the most part.

pillarsdotnet’s picture

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.)

PeteS’s picture

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.

vivianspencer’s picture

I had the same issues also, John's post http://drupal.org/node/112330#comment-192439 worked perfectly for me also