mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
updated security to not include insecure docs, only warning
This commit is contained in:
19
FAQ
19
FAQ
@@ -67,11 +67,6 @@ A: Be sure you set $compile_check=false once your templates are initially
|
||||
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.
|
||||
This way the editor won't view the template tags as errors.
|
||||
|
||||
Q: Do you have a mailing list?
|
||||
A: Yes. Subscribe by sending an e-mail to subscribe-smarty@lists.ispi.net. This
|
||||
is also archived at http://marc.theaimsgroup.com/?l=smarty&r=1&w=2
|
||||
@@ -144,3 +139,17 @@ 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
|
||||
dependant on it, and may become moreso in the future.
|
||||
|
||||
DREAMWEAVER
|
||||
-----------
|
||||
|
||||
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.
|
||||
This way the editor won't view the template tags as errors.
|
||||
|
||||
Q: Dreamweaver is urlencoding the template delimiters when they are in a SRC or
|
||||
HREF link. How do I get around this?
|
||||
A: In Edit - Properties - Rewrite HTML you can specify if Dreamweaver should
|
||||
change special letters to %-equivalent or not. The default is on which
|
||||
produces this error.
|
||||
|
2
NEWS
2
NEWS
@@ -1,5 +1,7 @@
|
||||
Version 1.4.4
|
||||
-------------
|
||||
- fixed problem with including insecure templates with security enabled
|
||||
(Monte)
|
||||
- numerous documentation updates. (Monte)
|
||||
- added ENT_QUOTES to escapement of html. (Monte, Sam Beckwith)
|
||||
- implemented access to request variables via auto-assigned $smarty
|
||||
|
@@ -568,25 +568,29 @@ class Smarty
|
||||
// buffering - for speed
|
||||
if ($display && !$this->caching) {
|
||||
echo $info_header;
|
||||
$this->_process_template($tpl_file, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
if($this->_process_template($tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ob_start();
|
||||
echo $info_header;
|
||||
$this->_process_template($tpl_file, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
if($this->_process_template($tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
$results = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
@@ -660,14 +664,16 @@ class Smarty
|
||||
|
||||
function _generate_debug_output() {
|
||||
ob_start();
|
||||
$this->_process_template($this->debug_tpl, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
if($this->_process_template($this->debug_tpl, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
}
|
||||
$results = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $results;
|
||||
@@ -689,7 +695,9 @@ function _generate_debug_output() {
|
||||
return true;
|
||||
} else {
|
||||
// get template source and timestamp
|
||||
$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp);
|
||||
if(!$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||
// template not expired, no recompile
|
||||
return true;
|
||||
@@ -702,7 +710,9 @@ function _generate_debug_output() {
|
||||
}
|
||||
} else {
|
||||
// compiled template does not exist, or forced compile
|
||||
$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp);
|
||||
if(!$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||
$this->_write_compiled_template($compile_path, $template_compiled);
|
||||
return true;
|
||||
@@ -869,17 +879,18 @@ function _generate_debug_output() {
|
||||
|
||||
array_unshift($this->_config, $this->_config[0]);
|
||||
|
||||
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
||||
if($this->_process_template($_smarty_include_tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
|
||||
include($compile_path);
|
||||
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
|
||||
array_shift($this->_config);
|
||||
$this->_inclusion_depth--;
|
||||
|
532
docs.sgml
532
docs.sgml
@@ -650,7 +650,7 @@ $smarty->assign(array("city" => "Lincoln","state" => "Nebraska"));
|
||||
console</link>, and should probably never be used directly.
|
||||
</para>
|
||||
<example>
|
||||
<title>assign</title>
|
||||
<title>assign_debug_info</title>
|
||||
<programlisting>
|
||||
|
||||
// passing name/value pairs
|
||||
@@ -876,7 +876,7 @@ function print_current_date ($params) {
|
||||
|
||||
// we don't want template designers to have access to system files
|
||||
|
||||
$smarty->unregister_modifier("fetch");
|
||||
$smarty->unregister_function("fetch");
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
@@ -2443,317 +2443,317 @@ e-mail: jane@mydomain.com<p>
|
||||
These are indicated by percent signs around the variable name, like so:
|
||||
%sectionname.varname%
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>index</title>
|
||||
<para>
|
||||
index is used to display the current loop index, starting with zero
|
||||
(or the start attribute if given), and incrementing by one (or by
|
||||
the step attribute if given.)
|
||||
</para>
|
||||
<para>
|
||||
TECHNICAL NOTE: If the step and start section properties are not
|
||||
modified, then this works the same as the iteration section
|
||||
property.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
<sect3>
|
||||
<title>index</title>
|
||||
<para>
|
||||
index is used to display the current loop index, starting with zero
|
||||
(or the start attribute if given), and incrementing by one (or by
|
||||
the step attribute if given.)
|
||||
</para>
|
||||
<para>
|
||||
TECHNICAL NOTE: If the step and start section properties are not
|
||||
modified, then this works the same as the iteration section
|
||||
property.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>index_prev</title>
|
||||
<para>
|
||||
index_prev is used to display the previous loop index.
|
||||
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: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
||||
The customer id changed<br>
|
||||
{/if}
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>index_prev</title>
|
||||
<para>
|
||||
index_prev is used to display the previous loop index.
|
||||
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: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
||||
The customer id changed<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
0 id: 1000<br>
|
||||
The customer id changed<br>
|
||||
1 id: 1001<br>
|
||||
The customer id changed<br>
|
||||
2 id: 1002<br>
|
||||
The customer id changed<br>
|
||||
0 id: 1000<br>
|
||||
The customer id changed<br>
|
||||
1 id: 1001<br>
|
||||
The customer id changed<br>
|
||||
2 id: 1002<br>
|
||||
The customer id changed<br>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>index_next</title>
|
||||
<para>
|
||||
index_next is used to display the next loop index. On the last
|
||||
loop, this is still one more than the current index (respecting the
|
||||
setting of the step attribute, if given.)
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index_next</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>index_next</title>
|
||||
<para>
|
||||
index_next is used to display the next loop index. On the last
|
||||
loop, this is still one more than the current index (respecting the
|
||||
setting of the step attribute, if given.)
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index_next</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
0 id: 1000<br>
|
||||
The customer id will change<br>
|
||||
1 id: 1001<br>
|
||||
The customer id will change<br>
|
||||
2 id: 1002<br>
|
||||
The customer id will change<br>
|
||||
0 id: 1000<br>
|
||||
The customer id will change<br>
|
||||
1 id: 1001<br>
|
||||
The customer id will change<br>
|
||||
2 id: 1002<br>
|
||||
The customer id will change<br>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration is used to display the current loop iteration.
|
||||
</para>
|
||||
<para>
|
||||
NOTE: This is not affected by the section properties start, step and
|
||||
max, unlike the index property.
|
||||
</para>
|
||||
<para>
|
||||
This was added to Smarty 1.4.4.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property iteration</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid start=5 step=2}
|
||||
current loop iteration: {%customer.iteration%}<br>
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration is used to display the current loop iteration.
|
||||
</para>
|
||||
<para>
|
||||
NOTE: This is not affected by the section properties start, step and
|
||||
max, unlike the index property.
|
||||
</para>
|
||||
<para>
|
||||
This was added to Smarty 1.4.4.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property iteration</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid start=5 step=2}
|
||||
current loop iteration: {%customer.iteration%}<br>
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
current loop iteration: 1
|
||||
5 id: 1000<br>
|
||||
The customer id will change<br>
|
||||
current loop iteration: 2
|
||||
7 id: 1001<br>
|
||||
The customer id will change<br>
|
||||
current loop iteration: 3
|
||||
9 id: 1002<br>
|
||||
The customer id will change<br>
|
||||
current loop iteration: 1
|
||||
5 id: 1000<br>
|
||||
The customer id will change<br>
|
||||
current loop iteration: 2
|
||||
7 id: 1001<br>
|
||||
The customer id will change<br>
|
||||
current loop iteration: 3
|
||||
9 id: 1002<br>
|
||||
The customer id will change<br>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<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%}
|
||||
<table>
|
||||
{/if}
|
||||
</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%}
|
||||
<table>
|
||||
{/if}
|
||||
|
||||
<tr><td>{%customer.index%} id:
|
||||
{$custid[customer]}</td></tr>
|
||||
<tr><td>{%customer.index%} id:
|
||||
{$custid[customer]}</td></tr>
|
||||
|
||||
{if %customer.last%}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
{if %customer.last%}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<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%}
|
||||
<table>
|
||||
{/if}
|
||||
</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%}
|
||||
<table>
|
||||
{/if}
|
||||
|
||||
<tr><td>{%customer.index%} id:
|
||||
{$custid[customer]}</td></tr>
|
||||
<tr><td>{%customer.index%} id:
|
||||
{$custid[customer]}</td></tr>
|
||||
|
||||
{if %customer.last%}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
{if %customer.last%}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>rownum</title>
|
||||
<para>
|
||||
rownum is used to display the current loop iteration,
|
||||
starting with one.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property rownum</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>rownum</title>
|
||||
<para>
|
||||
rownum is used to display the current loop iteration,
|
||||
starting with one.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property rownum</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>loop</title>
|
||||
<para>
|
||||
loop is used to display the last index number that this section
|
||||
looped. This can be used inside or after the section.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>loop</title>
|
||||
<para>
|
||||
loop is used to display the last index number that this section
|
||||
looped. This can be used inside or after the section.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property index</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
There were {%customer.loop%} customers shown above.
|
||||
There were {%customer.loop%} customers shown above.
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
|
||||
There were 3 customers shown above.
|
||||
There were 3 customers shown above.
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> is used as a parameter to section.
|
||||
<emphasis>show</emphasis> is a boolean value, true or false. If
|
||||
false, the section will not be displayed. If there is a sectionelse
|
||||
present, that will be alternately displayed.
|
||||
</para>
|
||||
<example>
|
||||
<title>section attribute show</title>
|
||||
<programlisting>
|
||||
{* $show_customer_info may have been passed from the PHP
|
||||
application, to regulate whether or not this section shows *}
|
||||
{section name=customer loop=$custid show=$show_customer_info}
|
||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> is used as a parameter to section.
|
||||
<emphasis>show</emphasis> is a boolean value, true or false. If
|
||||
false, the section will not be displayed. If there is a sectionelse
|
||||
present, that will be alternately displayed.
|
||||
</para>
|
||||
<example>
|
||||
<title>section attribute show</title>
|
||||
<programlisting>
|
||||
{* $show_customer_info may have been passed from the PHP
|
||||
application, to regulate whether or not this section shows *}
|
||||
{section name=customer loop=$custid show=$show_customer_info}
|
||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
{if %customer.show%}
|
||||
the section was shown.
|
||||
{else}
|
||||
the section was not shown.
|
||||
{/if}
|
||||
{if %customer.show%}
|
||||
the section was shown.
|
||||
{else}
|
||||
the section was not shown.
|
||||
{/if}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
|
||||
the section was shown.
|
||||
the section was shown.
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>total</title>
|
||||
<para>
|
||||
total is used to display the number of iterations that this section
|
||||
will loop. This can be used inside or after the section.
|
||||
</para>
|
||||
<para>
|
||||
This was added to Smarty 1.4.4.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property total</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid step=2}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
<sect3>
|
||||
<title>total</title>
|
||||
<para>
|
||||
total is used to display the number of iterations that this section
|
||||
will loop. This can be used inside or after the section.
|
||||
</para>
|
||||
<para>
|
||||
This was added to Smarty 1.4.4.
|
||||
</para>
|
||||
<example>
|
||||
<title>section property total</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid step=2}
|
||||
{%customer.index%} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
There were {%customer.total%} customers shown above.
|
||||
There were {%customer.total%} customers shown above.
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
0 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
4 id: 1002<br>
|
||||
0 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
4 id: 1002<br>
|
||||
|
||||
There were 3 customers shown above.
|
||||
There were 3 customers shown above.
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect3>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>strip</title>
|
||||
@@ -3400,7 +3400,7 @@ OUTPUT:
|
||||
<title>html_select_time</title>
|
||||
<programlisting>
|
||||
|
||||
{html_select_time use_24_hours=false}
|
||||
{html_select_time use_24_hours=true}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
@@ -568,25 +568,29 @@ class Smarty
|
||||
// buffering - for speed
|
||||
if ($display && !$this->caching) {
|
||||
echo $info_header;
|
||||
$this->_process_template($tpl_file, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
if($this->_process_template($tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ob_start();
|
||||
echo $info_header;
|
||||
$this->_process_template($tpl_file, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
if($this->_process_template($tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
$results = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
@@ -660,14 +664,16 @@ class Smarty
|
||||
|
||||
function _generate_debug_output() {
|
||||
ob_start();
|
||||
$this->_process_template($this->debug_tpl, $compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
if($this->_process_template($this->debug_tpl, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||
}
|
||||
}
|
||||
$results = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $results;
|
||||
@@ -689,7 +695,9 @@ function _generate_debug_output() {
|
||||
return true;
|
||||
} else {
|
||||
// get template source and timestamp
|
||||
$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp);
|
||||
if(!$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||
// template not expired, no recompile
|
||||
return true;
|
||||
@@ -702,7 +710,9 @@ function _generate_debug_output() {
|
||||
}
|
||||
} else {
|
||||
// compiled template does not exist, or forced compile
|
||||
$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp);
|
||||
if(!$this->_fetch_template_source($tpl_file, $template_source, $template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||
$this->_write_compiled_template($compile_path, $template_compiled);
|
||||
return true;
|
||||
@@ -869,17 +879,18 @@ function _generate_debug_output() {
|
||||
|
||||
array_unshift($this->_config, $this->_config[0]);
|
||||
|
||||
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
||||
if($this->_process_template($_smarty_include_tpl_file, $compile_path))
|
||||
{
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_BEGIN: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
include($compile_path);
|
||||
|
||||
include($compile_path);
|
||||
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
if ($this->show_info_include) {
|
||||
echo "\n<!-- SMARTY_END: ".$_smarty_include_tpl_file." -->\n";
|
||||
}
|
||||
}
|
||||
|
||||
array_shift($this->_config);
|
||||
$this->_inclusion_depth--;
|
||||
|
Reference in New Issue
Block a user