Jump to content

Clearing product-specific module template cache


gabeshackle

Recommended Posts

I have a module that allows the admin to select from a number of optional blocks of HTML to be displayed on the product detail page.  The content of each of these blocks is editable via the module's configuration screen.  The problem I'm having is determining how to clear the cache on the these templates as I may want to clear the template for just the single product if that particular product is edited but I also would want to clear all instances of those templates of the module configuration changes.

 

I'm using 1.6.0.6.

 

Basically I'd like to know if there's a way to clear all caches, regardless of cache id, associated with a particular template file.

 

Here is my code for creating the cache on a product by product basis:

if (!$this->isCached('mytemplate.tpl', $this->getCacheId($unique_product_string) )) {
	$this->smarty->assign(array(
		'title' => Configuration::get( 'title' ),
		'description' => Configuration::get( 'description' )
	));
}

return $this->display(__FILE__, 'mytemplate.tpl', $this->getCacheId($unique_product_string) );

And the code to clear the cache for that template (which returns 0 clears every time):

$this->_clearCache('mytemplate.tpl');
Edited by gabeshackle (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...