added $check_cached_insert_tags to speed up cached pages if

{insert ...} is not used (Monte)
This commit is contained in:
mohrt
2001-04-13 20:08:32 +00:00
parent 1ddce1c67e
commit cd0e8ccfca
5 changed files with 70 additions and 13 deletions

12
FAQ
View File

@@ -66,6 +66,7 @@ Q: Do you have a mailing list?
A: Yes. Subscribe by sending an e-mail to subscribe-smarty@lists.ispi.net. This A: Yes. Subscribe by sending an e-mail to subscribe-smarty@lists.ispi.net. This
is also archived at http://marc.theaimsgroup.com/ under www/smarty is also archived at http://marc.theaimsgroup.com/ under www/smarty
TROUBLESHOOTING TROUBLESHOOTING
--------------- ---------------
@@ -126,5 +127,12 @@ A: This was fixed in 1.3.2 (new global attribute)
Q: How can I tell what compiled template file corresponds to to which source Q: How can I tell what compiled template file corresponds to to which source
file? (Smarty 1.4.0 and later have encoded compiled filenames) file? (Smarty 1.4.0 and later have encoded compiled filenames)
A: Compiled template files have headers that tell which source file was used to A: Compiled template files have headers that tell which source file was used to
compile it. cd into the compile_dir and type "head -2 *" to see the first compile it. Grep for the pathname, or use "head -2 *" to see the first two
two lines of each compiled file. lines of each compiled file.
Q: My ISP did not setup the PEAR repository, nor will they set it up. How do I
make Smarty run without it?
A: The easiest thing to do is grab all of PEAR and install it locally for your
own use. There's nothing that says PEAR must be installed in its default
directory. There won't be a version of Smarty that runs without PEAR, as it
quite dependant on it, especially with database support.

2
NEWS
View File

@@ -1,3 +1,5 @@
- added $check_cached_insert_tags to speed up cached pages if
{insert ...} is not used (Monte)
- added $compiler_class variable to allow specifying a different compiler - added $compiler_class variable to allow specifying a different compiler
class. (Andrei) class. (Andrei)
- changed Smarty to compile templates at runtime, allowing for arbitrary - changed Smarty to compile templates at runtime, allowing for arbitrary

View File

@@ -5,13 +5,13 @@ The most significant change to Smarty 1.4.0 is the compilation process. Instead
of compiling all the templates up front, it now compiles them at runtime. This of compiling all the templates up front, it now compiles them at runtime. This
has several advantages. First off, there is no longer a need to have a single has several advantages. First off, there is no longer a need to have a single
template directory. You can now have arbitrary template sources, such as template directory. You can now have arbitrary template sources, such as
multiple directories or even database calls. This also speeds the performance of multiple directories or even database calls. This also speeds the performance
Smarty when $compile_check is enabled, since it is only checking the template of Smarty when $compile_check is enabled, since it is only checking the
that is being executed instead of everything found in the template directory. template that is being executed instead of everything found in the template
The $tpl_file_ext variable was removed since this is no longer needed, so directory. The $tpl_file_ext is no longer needed, but kept for backward
templates can be named anything you like with any extension. Smarty makes use of compatability. Templates can now be named anything you like with any extension.
the PEAR database abstraction class for obtaining templates from databases. Now Smarty makes use of the PEAR database abstraction class for obtaining templates
aren't you glad we require PEAR :-) from databases.
We also added a workaround for LOCK_EX on Windows systems, and changed a couple We also added a workaround for LOCK_EX on Windows systems, and changed a couple
of file permissions for better security on public servers. Thanks goes to of file permissions for better security on public servers. Thanks goes to
@@ -21,7 +21,7 @@ date_format, html_select_date and html_select_time used to require a unix
timestamp as the format of the date passed into the template. Smarty is now a timestamp as the format of the date passed into the template. Smarty is now a
bit smarter at this. It will take a unix timestamp, a mysql timestamp, or any bit smarter at this. It will take a unix timestamp, a mysql timestamp, or any
date string that is parsable by strtotime, such as 10/01/2001 or 2001-10-01, date string that is parsable by strtotime, such as 10/01/2001 or 2001-10-01,
etc. Just give it a try and see what works. etc. Just give some formats a try and see what works.
When upgrading to 1.4.0, you will want to first clear out all your files in the When upgrading to 1.4.0, you will want to first clear out all your files in the
$compile_dir, since it now uses a new format. Since templates can come from any $compile_dir, since it now uses a new format. Since templates can come from any
@@ -32,4 +32,35 @@ false and the compiled template does not yet exist, it will compile it
regardless of this setting. Once it is compiled though, it will not check to see regardless of this setting. Once it is compiled though, it will not check to see
if recompilation is necessary. if recompilation is necessary.
-Monte 1.3.2
-----
Smarty now has (an optional) header prepended to the output of the Smarty
templates. This displays the Smarty version and the date/time when the page was
generated. This is useful for debugging your cache routines, and purely
informational so there is evidence that the page was generated by Smarty. Set
$show_info_header to false to disable it.
{config_load ...} performance was tuned by placing the loaded variables into a
global array, so basically a config file is read from the file system and
placed into a php array structure only once, no matter how many times it is
called in any of the templates. The scope of the loaded variables has changed a
bit as well. Variables loaded by config_load used to be treated as global
variables, meaning that parent templates (templates that included the current
template) could see them. Now the default behavior is such that loaded
variables are only visible by the current template and child templates (all
templates included after the {config_load ...} is called.) To mimic the
original behavior, provide the attribute "global=yes" like so: {config_load
file="mystuff.conf" global=yes}. Now when you load in mystuff.conf, the
variables will be visible to parent templates (merged with any existing config
variables.)
A formatting attribute was added to the {math ...} function, adding the ability
to control the format of the output. Use the same formatting syntax as the PHP
function sprintf().
{html_select_time ...} was added, a custom function that works much like
{html_select_date ...} except it displays time elements instead of dates.
A few custom modifiers were added: count_characters, count_words,
count_sentences, count_paragraphs. All pretty self-explanatory.

View File

@@ -78,6 +78,12 @@ class Smarty
var $cache_dir = './cache'; // name of directory for template cache var $cache_dir = './cache'; // name of directory for template cache
var $cache_lifetime = 3600; // number of seconds cached content will persist. var $cache_lifetime = 3600; // number of seconds cached content will persist.
// 0 = never expires. default is one hour (3600) // 0 = never expires. default is one hour (3600)
var $check_cached_insert_tags = true; // if you have caching turned on and you
// don't use {insert} tags anywhere
// in your templates, set this to false.
// this will tell Smarty not to look for
// insert tags and speed up cached page
// fetches.
var $tpl_file_ext = '.tpl'; // template file extention var $tpl_file_ext = '.tpl'; // template file extention
@@ -361,7 +367,9 @@ class Smarty
($this->cache_lifetime == 0 || ($this->cache_lifetime == 0 ||
(time() - filemtime($cache_file) <= $this->cache_lifetime))) { (time() - filemtime($cache_file) <= $this->cache_lifetime))) {
$results = $this->_read_file($cache_file); $results = $this->_read_file($cache_file);
if($this->check_cached_insert_tags) {
$results = $this->_process_cached_inserts($results); $results = $this->_process_cached_inserts($results);
}
if ($display) { if ($display) {
echo $results; echo $results;
return; return;

View File

@@ -78,6 +78,12 @@ class Smarty
var $cache_dir = './cache'; // name of directory for template cache var $cache_dir = './cache'; // name of directory for template cache
var $cache_lifetime = 3600; // number of seconds cached content will persist. var $cache_lifetime = 3600; // number of seconds cached content will persist.
// 0 = never expires. default is one hour (3600) // 0 = never expires. default is one hour (3600)
var $check_cached_insert_tags = true; // if you have caching turned on and you
// don't use {insert} tags anywhere
// in your templates, set this to false.
// this will tell Smarty not to look for
// insert tags and speed up cached page
// fetches.
var $tpl_file_ext = '.tpl'; // template file extention var $tpl_file_ext = '.tpl'; // template file extention
@@ -361,7 +367,9 @@ class Smarty
($this->cache_lifetime == 0 || ($this->cache_lifetime == 0 ||
(time() - filemtime($cache_file) <= $this->cache_lifetime))) { (time() - filemtime($cache_file) <= $this->cache_lifetime))) {
$results = $this->_read_file($cache_file); $results = $this->_read_file($cache_file);
if($this->check_cached_insert_tags) {
$results = $this->_process_cached_inserts($results); $results = $this->_process_cached_inserts($results);
}
if ($display) { if ($display) {
echo $results; echo $results;
return; return;