function.prevent_caching.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /*
13 * Smarty plugin
14 * -------------------------------------------------------------
15 * File: function.prevent_caching.php
16 * Type: function
17 * Name: prevent_caching
18 * Purpose: prevents caching of an url by adding a unique parameter to the url
19 * (default parameter name is cacheKiller, to change it pass a name in the
20  'name' parameter)
21 * Usage: e.g. {prevent_cache url="title.gif"} or {prevent_cache url="title.gif" name="uid"}
22 * -------------------------------------------------------------
23 */
24 function smarty_function_prevent_caching($params, \Smarty_Internal_Template $template) {
25  if (isset($params['name'])) {
26  $params['name'] = 'cacheKiller';
27  }
28  echo $params['url']."?".$params['name']."=".uniqid((double)microtime()*1000000,1);
29 }
30 ?>