update changelog

This commit is contained in:
mohrt
2001-03-02 22:54:21 +00:00
parent 86808e9cee
commit d1ca3a4454
3 changed files with 203 additions and 74 deletions

32
FAQ
View File

@@ -38,26 +38,24 @@ A: Smarty and these cache solutions have nothing in common. What APC does is
not.
Q: Is Smarty faster than <insert other PHP template engine>?
A: This would mostly depend on the other template engine, but as a general rule
of thumb: Without a PHP caching solution like APC or Zend Cache, Smarty is
most likely as fast, or possibly slower. With APC, Smarty is mostly like as
fast or much faster. The reason is this: Smarty generates PHP scripts from
your templates. The more templates your application has, the more PHP
scripts Smarty generates. This in turn requires more time for the PHP parser
to compile the PHP scripts. With APC, this compilation step is cached. So as
the complexity of the templates increase, the performance savings go up
accordingly. Also, most other template solutions parse the template files on
each invocation. The more complex the templates are, the longer they take to
parse. Smarty has no need to parse template files, it only executes PHP
scripts. We are working on a release of Smarty that will be noticably
quicker even without the aid of a PHP script caching solution by minimizing
the amount of PHP code that is compiled on each request.
A: It could be. One of the strengths of Smarty is that it does not need to
parse the template files on every hit to the server. Version 1.3.1 has
many noticable performance tune-ups, so your best bet is to try some
benchmarks and compare for yourself.
The above comparison assumes that you are not using Smarty's built-in
ability to cache templates. If you are, that makes this comparison pretty
useless since Smarty will basically be displaying static content instead of
generating templates, which of course will be magnitudes faster.
unfair since Smarty will basically be displaying static content instead of
generating templates, which will speed things up, especially for compilcated
templates.
Q: How can I be sure to get the best performance from Smarty?
A Be sure you set $compile_check=false once your templates are initially
compiled. This will skip the unneeded step of traversing all of your template files on each hit. If you have complex pages that don't change too often,
turn on the caching engine and adjust your application so it doesn't do
unnecessary work (like db calls) if a cached page is available. See the
documentation for examples.
Q: Can I use Macromedia's Dreamweaver to edit my templates?
A: Certainly. You might want to change your tag delimiters from {} to something
that resembles valid HTML, like <!--{ }--> or <{ }> or something similar.

2
NEWS
View File

@@ -1,6 +1,8 @@
- document first, last, index_prev, index_next (Monte)
- added 'first' and 'last' section properties. (Andrei)
- split out compiling code to separate class for faster template execution
time (Monte)
- fixed a couple of minor PHP warnings (Monte)
- added and documented unregister_modifier() and unregister_function() API
calls. (Monte)
- added and documented 'fetch' and 'math' functions. (Monte)

243
docs.sgml
View File

@@ -580,6 +580,59 @@ function print_current_date ($params) {
// now you can use this in Smarty to print the current date: {date_now}
// or, {date_now format="%Y/%m/%d"} to format it.
</programlisting>
</example>
</sect2>
<sect2 id="api.clear.cache">
<title>clear_cache</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>clear_cache</function></funcdef>
<paramdef>string <parameter>template</parameter></paramdef>
<paramdef>string <parameter>cache id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This clears the cache for the specified template. If you have
multiple caches for this template, you can clear a specific
cache by supplying the cache id as the second parameter. See the
<link linkend="section.caching">caching section</link> for more
information. This was added to Smarty 1.3.0.
</para>
<example>
<title>clear_cache</title>
<programlisting>
// clear the cache for a template
$smarty->clear_cache("index.tpl");
// clear the cache for a particular cache id in an multiple-cache template
$smarty->clear_cache("index.tpl","CACHEID");
</programlisting>
</example>
</sect2>
<sect2 id="api.clear.all.cache">
<title>clear_all_cache</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>clear_all_cache</function></funcdef>
<paramdef><parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This clears the entire template cache. This was added to Smarty
1.3.0.
</para>
<example>
<title>clear_all_cache</title>
<programlisting>
// clear the entire cache
$smarty->clear_all_cache();
</programlisting>
</example>
</sect2>
@@ -653,59 +706,6 @@ $smarty->register_modifier("sslash","stripslashes");
$smarty->unregister_modifier("strip_tags");
</programlisting>
</example>
</sect2>
<sect2 id="api.clear.cache">
<title>clear_cache</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>clear_cache</function></funcdef>
<paramdef>string <parameter>template</parameter></paramdef>
<paramdef>string <parameter>cache id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This clears the cache for the specified template. If you have
multiple caches for this template, you can clear a specific
cache by supplying the cache id as the second parameter. See the
<link linkend="section.caching">caching section</link> for more
information. This was added to Smarty 1.3.0.
</para>
<example>
<title>clear_cache</title>
<programlisting>
// clear the cache for a template
$smarty->clear_cache("index.tpl");
// clear the cache for a particular cache id in an multiple-cache template
$smarty->clear_cache("index.tpl","CACHEID");
</programlisting>
</example>
</sect2>
<sect2 id="api.clear.all.cache">
<title>clear_all_cache</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>clear_all_cache</function></funcdef>
<paramdef><parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This clears the entire template cache. This was added to Smarty
1.3.0.
</para>
<example>
<title>clear_all_cache</title>
<programlisting>
// clear the entire cache
$smarty->clear_all_cache();
</programlisting>
</example>
</sect2>
@@ -1646,6 +1646,134 @@ OUTPUT:
1 id: 1001&lt;br&gt;
2 id: 1002&lt;br&gt;
</programlisting>
</example>
</sect3>
<sect3>
<title>index_prev</title>
<para>
index_prev is used to display the previous loop iteration.
on the first loop, this is set to -1.
</para>
<example>
<title>section property index_prev</title>
<programlisting>
{section name=customer loop=$custid}
{%customer.index%} id: {$customer/custid}&lt;br&gt;
{* FYI, $customer.index/custid and $customer/custid are identical in meaning *}
{if $customer.index_prev/custid ne $customer.index/custid}
The customer id changed&lt;br&gt;
{/if}
{/section}
OUTPUT:
0 id: 1000&lt;br&gt;
The customer id changed&lt;br&gt;
1 id: 1001&lt;br&gt;
The customer id changed&lt;br&gt;
2 id: 1002&lt;br&gt;
The customer id changed&lt;br&gt;
</programlisting>
</example>
</sect3>
<sect3>
<title>index_next</title>
<para>
index_next is used to display the next loop iteration. On the last
loop, this is still one more than the current index.
</para>
<example>
<title>section property index_next</title>
<programlisting>
{section name=customer loop=$custid}
{%customer.index%} id: {$customer/custid}&lt;br&gt;
{* FYI, $customer.index/custid and $customer/custid are identical in meaning *}
{if $customer.index_next/custid ne $customer.index/custid}
The customer id will change&lt;br&gt;
{/if}
{/section}
OUTPUT:
0 id: 1000&lt;br&gt;
The customer id will change&lt;br&gt;
1 id: 1001&lt;br&gt;
The customer id will change&lt;br&gt;
2 id: 1002&lt;br&gt;
The customer id will change&lt;br&gt;
</programlisting>
</example>
</sect3>
<sect3>
<title>first</title>
<para>
first is set to true if the current section iteration is the first
one.
</para>
<example>
<title>section property first</title>
<programlisting>
{section name=customer loop=$custid}
{if %customer.first%}
&lt;table&gt;
{/if}
&lt;tr&gt;&lt;td&gt;{%customer.index%} id:
{$customer/custid}&lt;/td&gt;&lt;/tr&gt;
{if %customer.last%}
&lt;/table&gt;
{/if}
{/section}
OUTPUT:
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;0 id: 1000&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1 id: 1001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2 id: 1002&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</programlisting>
</example>
</sect3>
<sect3>
<title>last</title>
<para>
last is set to true if the current section iteration is the last
one.
</para>
<example>
<title>section property last</title>
<programlisting>
{section name=customer loop=$custid}
{if %customer.first%}
&lt;table&gt;
{/if}
&lt;tr&gt;&lt;td&gt;{%customer.index%} id:
{$customer/custid}&lt;/td&gt;&lt;/tr&gt;
{if %customer.last%}
&lt;/table&gt;
{/if}
{/section}
OUTPUT:
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;0 id: 1000&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1 id: 1001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2 id: 1002&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</programlisting>
</example>
</sect3>
@@ -1821,7 +1949,7 @@ OUTPUT:
</informaltable>
<para>
fetch allows the template designer to fetch files from the local
file system, ftp, or http, and display the contents. If the file
file system, http, or ftp and display the contents. If the file
name begins with "http://", the web site page will be fetched and
displayed. If the file name begins with "ftp://", the file will be
fetched from the ftp server and displayed. For local files, the full
@@ -1835,9 +1963,10 @@ OUTPUT:
<para>
TECHNICAL NOTE: This function may be a security concern if you are
allowing third parties to modify templates. i.e., they can access
arbitrary files on your system. Be sure to <link
linkend="api.unregister.function">unregister</link> this function if
required.
files on your system out side of the template directory. To disable
this function, <link
linkend="api.unregister.function">unregister</link> it in your
application.
</para>
<example>
<title>fetch</title>