Re: [SMARTY] cache and inserts

From: Date: Fri, 06 Jun 2003 09:10:13 +0000
Subject: Re: [SMARTY] cache and inserts
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9655@lists.php.net to get a copy of this message
Paul Lockaby wrote in php.smarty.general: > Nino Katic wrote: >> Is it possible to turn off cacheing but to be able to use inserts in >> tpls? This is because i have many inserts and the speed gained with >> cache is questionable. So, is this possible? > Yes, it is possible. However, inserts are horribly slow. If there is a > better way to do what you're doing without using inserts (perhaps > includes instead?) then you might want to try that. BTW: sometimes you might use the same codebase for "include" and insert depending on the situation. I use a template function as wrapper for insert-plugins to allow caching the output: function smarty_function_static($params, &$smarty) { $function_name = 'smarty_insert_' . $params['name']; if (!function_exists($function_name)) { $plugin_file = $smarty->_get_plugin_filepath('insert', $params['name']); require_once $plugin_file; } $params['static'] = true; $output = $function_name($params, $smarty); return $output; } If you won't prevent the output of an insert-plugin from caching you simply call: {static name="my_insert_plugin"} To prevent the output from caching call the plugin as usual: {insert name="my_insert_plugin"} ThS. -- http://4bconsult.de

« previous php.smarty.general (#9655) next »