Disable Cache For Certain Blocks Or Parts?

In my Default Header, i placed a Grid, with a block in there,



the block type is HTML with Smarty support,



with the code:

```php

{if $mode eq 'cart' or $mode eq 'checkout'}

Secure checkout

{/if}
```

So a "Secure checkout" banner popups up whenever a user is inside the Cart or Checkout of my store.

Problem is that I have Caching on, and im on CS Cart version 4.3.2 now.

And this part is stored in the Cache, so It will not change according to a users "mode" location.

It will show the cached version. So "Secure checkout" only pops up when I entirely disable or empty the Cache.

Is there any way of disabling the Cache for certain parts of code or certain TPL files?

What is a better way of achieving this?

Thanks for thinking along!

secure checkout.PNG

Try open the app\schemas\block_manager\blocks.php file and replace:



'smarty_block' => array (
'content' => array (
'content' => array (
'type' => 'simple_text',
'required' => true,
)
),
'templates' => 'blocks/smarty_block.tpl',
'wrappers' => 'blocks/wrappers',
'multilanguage' => true,
'cache' => true
),




with



'smarty_block' => array (
'content' => array (
'content' => array (
'type' => 'simple_text',
'required' => true,
)
),
'templates' => 'blocks/smarty_block.tpl',
'wrappers' => 'blocks/wrappers',
'multilanguage' => true,
'cache' => false
),




Then clear the cache and check the result

Perfect fix! And luckely without having to shut down the cache for a big part of the webshop, only Smarty Blocks are not cached now,

So performance is still super.



This is the second time in 2 days the eComLabs saves the day, thanks everyone for reading!

You are welcome!