Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy wedding dresses on SiteSteer.com - Best Online Wedding Dress Store

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

Cache Groups

You can do more elaborate grouping by setting up $cache_id groups. This is accomplished by separating each sub-group with a vertical bar | in the $cache_id value. You can have as many sub-groups as you like.

  • You can think of cache groups like a directory hierarchy. For instance, a cache group of 'a|b|c' could be thought of as the directory structure '/a/b/c/'.

  • clear_cache(null,'a|b|c') would be like removing the files '/a/b/c/*'. clear_cache(null,'a|b') would be like removing the files '/a/b/*'.

  • If you specify a $compile_id such as clear_cache(null,'a|b','foo') it is treated as an appended cache group '/a/b/c/foo/'.

  • If you specify a template name such as clear_cache('foo.tpl','a|b|c') then Smarty will attempt to remove '/a/b/c/foo.tpl'.

  • You CANNOT remove a specified template name under multiple cache groups such as '/a/b/*/foo.tpl', the cache grouping works left-to-right ONLY. You will need to group your templates under a single cache group heirarchy to be able to clear them as a group.

Cache grouping should not be confused with your template directory heirarchy, the cache grouping has no knowledge of how your templates are structured. So for example, if you have a template structure like themes/blue/index.tpl and you want to be able to clear all the cache files for the blue theme, you will need to create a cache group structure that mimics your template file structure, such as display('themes/blue/index.tpl','themes|blue'), then clear them with clear_cache(null,'themes|blue').

Example 14.9. $cache_id groups


<?php
require('Smarty.class.php');
$smarty = new Smarty;

$smarty->caching = true;

// clear all caches with 'sports|basketball' as the first two cache_id groups
$smarty->clear_cache(null,'sports|basketball');

// clear all caches with "sports" as the first cache_id group. This would
// include "sports|basketball", or "sports|(anything)|(anything)|(anything)|..."
$smarty->clear_cache(null,'sports');

// clear the foo.tpl cache file with "sports|basketball" as the cache_id
$smarty->clear_cache('foo.tpl','sports|basketball');


$smarty->display('index.tpl','sports|basketball');
?>

      

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 16 plus 19? (Are you human?)

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
Buy from China @dhgate.com
First Click Internet Marketing @fcinternetmarketing.com