2001-04-11 20:54:35 +00:00
|
|
|
1.4.0
|
|
|
|
-----
|
|
|
|
|
2001-04-19 21:08:17 +00:00
|
|
|
IMPORTANT NOTICE
|
|
|
|
|
|
|
|
Smarty now has a new syntax for accessing elements within section loops. The
|
|
|
|
new syntax is easier to use and nicely handles data structures of any
|
|
|
|
complexity. Consequently, this breaks the old syntax. To fix your current
|
|
|
|
templates, we have provided a script that will adjust the syntax for you.
|
|
|
|
Located in misc/fix_vars.php, run this script from the the command line, giving
|
|
|
|
each template as an argument. Be sure to use absolute pathnames, or pathnames
|
2001-04-16 17:39:59 +00:00
|
|
|
relative to the executing script. Probably the easiest way to do this is to
|
|
|
|
copy the fix_vars.php script into your template directory and run 'php -q
|
2001-04-19 16:18:17 +00:00
|
|
|
fix_vars.php *.tpl' Be sure you have proper write permission, and backup your
|
|
|
|
scripts first to be safe! The examples in the 1.4.0 documentation have been
|
|
|
|
updated to reflect the changes.
|
2001-04-16 17:39:59 +00:00
|
|
|
|
2001-04-24 15:16:14 +00:00
|
|
|
cd /path/to/templates
|
|
|
|
cp /path/to/fix_vars.php .
|
|
|
|
find . -name "*.tpl" -exec php -q ./fix_vars.php {} \;
|
|
|
|
|
2001-04-25 15:49:51 +00:00
|
|
|
NEW AND IMPROVED COMPILATION PROCESS
|
2001-04-19 21:08:17 +00:00
|
|
|
|
2001-04-16 17:39:59 +00:00
|
|
|
Smarty 1.4.0 also has a new compilation process. Instead of compiling all the
|
|
|
|
templates up front, it now compiles them at runtime. This has several
|
|
|
|
advantages. First of all, there is no longer a need to have a single template
|
|
|
|
directory. You can now have arbitrary template sources, such as multiple
|
|
|
|
directories or even database calls. This also speeds the performance of Smarty
|
|
|
|
when $compile_check is enabled, since it is only checking the template that is
|
|
|
|
being executed instead of everything found in the template directory. The
|
|
|
|
$tpl_file_ext is no longer needed, but kept for backward compatability.
|
2001-04-19 16:18:17 +00:00
|
|
|
Templates can now be named anything you like with any extension.
|
2001-04-11 20:54:35 +00:00
|
|
|
|
2001-04-19 21:08:17 +00:00
|
|
|
MINOR FIXES
|
|
|
|
|
2001-04-19 16:18:17 +00:00
|
|
|
A workaround for LOCK_EX on Windows systems was added, and changed a couple of
|
2001-04-19 21:08:17 +00:00
|
|
|
file permissions for better security on public servers.
|
|
|
|
|
2001-04-24 15:29:33 +00:00
|
|
|
$show_info_header is now defaulted to false instead of true. This header causes
|
|
|
|
problems when displaying content other than HTML, so now you must explicitly
|
|
|
|
set this flag to true to show the header information (or change the default in
|
|
|
|
your copy of Smarty.)
|
|
|
|
|
2001-04-19 21:08:17 +00:00
|
|
|
CHANGES/ENHANCEMENTS
|
2001-04-11 20:54:35 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
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,
|
2001-04-13 20:08:32 +00:00
|
|
|
etc. Just give some formats a try and see what works.
|
2001-04-11 20:54:35 +00:00
|
|
|
|
2001-04-19 21:08:17 +00:00
|
|
|
Smarty now has template filters, meaning that you can run your templates
|
|
|
|
through custom functions before they are compiled. This is good for things like
|
2001-04-25 14:52:52 +00:00
|
|
|
removing unwanted comments, keeping an eye on words or functionality people are
|
|
|
|
putting in templates, translating XML -> HTML, etc. See the register_filter
|
|
|
|
documentation for more info.
|
2001-04-19 21:08:17 +00:00
|
|
|
|
2001-04-25 15:49:51 +00:00
|
|
|
Another addition are the so-called compiler functions. These are custom
|
|
|
|
functions registered by the user that are executed at compilation time of the
|
|
|
|
template. They can be used to inject PHP code or time-sensitive static content
|
|
|
|
into the compiled template.
|
|
|
|
|
|
|
|
The run-time custom functions are now passed Smarty object as the second
|
|
|
|
parameter. This can be used, for example, to assign or clear template variables
|
|
|
|
from inside the custom function.
|
|
|
|
|
2001-04-26 16:08:12 +00:00
|
|
|
You can now refer to properties of objects assigned from PHP by using the '->'
|
|
|
|
symbol and specifying the property name after it, e.g. $foo->bar.
|
|
|
|
|
2001-04-19 21:08:17 +00:00
|
|
|
UPGRADE NOTES
|
|
|
|
|
2001-04-24 15:16:14 +00:00
|
|
|
The format of the files created in the $compile_dir are now a bit different.
|
|
|
|
The compiled template filename is the template resource name url-encoded.
|
|
|
|
Therefore, all compiled files are now in the top directory of $compile_dir.
|
|
|
|
This was done to make way for arbitrary template resources. Each compiled
|
|
|
|
template has a header that states what template resource was used to create it.
|
|
|
|
From a unix command prompt, you can use "head -2 *" to see the first two lines
|
|
|
|
of each file.
|
|
|
|
|
|
|
|
When upgrading to 1.4.0, you will want to clear out all your old files in the
|
|
|
|
$compile_dir. If you have $compile_check set to false and the compiled template
|
|
|
|
does not yet exist, it will compile it regardless of this setting. This way you
|
|
|
|
can clear out the $compile_dir and not worry about setting $compile_check to
|
|
|
|
true to get the inital compilation under way.
|
2001-04-11 20:54:35 +00:00
|
|
|
|
2001-04-13 20:08:32 +00:00
|
|
|
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.
|