mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
add "once" attribute to php_include, update docs
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,3 +1,5 @@
|
||||
- added "once" attribute to php_include (Monte)
|
||||
|
||||
Version 2.1.1
|
||||
-------------
|
||||
- added cycle function. (Monte)
|
||||
|
@@ -1092,7 +1092,7 @@ function _generate_debug_output() {
|
||||
Function: _smarty_include_php()
|
||||
Purpose: called for included templates
|
||||
\*======================================================================*/
|
||||
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign)
|
||||
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once)
|
||||
{
|
||||
$this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type,
|
||||
$_smarty_php_resource);
|
||||
@@ -1100,7 +1100,11 @@ function _generate_debug_output() {
|
||||
if (!empty($_smarty_assign)) {
|
||||
ob_start();
|
||||
if ($_smarty_resource_type == 'file') {
|
||||
include_once($_smarty_php_resource);
|
||||
if($_smarty_once) {
|
||||
include_once($_smarty_php_resource);
|
||||
} else {
|
||||
include($_smarty_php_resource);
|
||||
}
|
||||
} else {
|
||||
eval($_smarty_php_resource);
|
||||
}
|
||||
@@ -1108,7 +1112,11 @@ function _generate_debug_output() {
|
||||
ob_end_clean();
|
||||
} else {
|
||||
if ($_smarty_resource_type == 'file') {
|
||||
include_once($_smarty_php_resource);
|
||||
if($_smarty_once) {
|
||||
include_once($_smarty_php_resource);
|
||||
} else {
|
||||
include($_smarty_php_resource);
|
||||
}
|
||||
} else {
|
||||
eval($_smarty_php_resource);
|
||||
}
|
||||
|
@@ -632,8 +632,10 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
$assign_var = $this->_dequote($attrs['assign']);
|
||||
|
||||
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var'); ?>";
|
||||
|
||||
$once_var = ( $attrs['once'] === false ) ? 'false' : 'true';
|
||||
|
||||
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>";
|
||||
}
|
||||
|
||||
|
||||
|
22
TESTIMONIALS
22
TESTIMONIALS
@@ -57,3 +57,25 @@
|
||||
have to work late all week re-writing our FastTemplate site :)"
|
||||
|
||||
-- Robert V. Zwink
|
||||
|
||||
|
||||
"Hello, sorry for my english, i'm french ...
|
||||
|
||||
I've just discovered SMARTY ...
|
||||
I've tested it ...
|
||||
What a wonderful well-thinked product !!!
|
||||
I am a fan of XML/XSLT, but with server-side script ; it's not "easy" to
|
||||
build something strong.
|
||||
But with smarty ; it's wonderful to separate the look from the code ... and
|
||||
such easy ...
|
||||
I've tested others templates system, no-one is better ...
|
||||
I can't find my words in english to describe how many this product is
|
||||
WELL-THINKED, and such good ...
|
||||
|
||||
it's GREAT GREAT GREAT !
|
||||
And will use it for ever ...
|
||||
|
||||
thanx A LOT for your good work !!!
|
||||
you'll must have a "medal of honnor" for this product !"
|
||||
|
||||
-- Marc Lentz
|
||||
|
@@ -1637,6 +1637,14 @@ cell: 760-1234<br></programlisting>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the php file to include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>once</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>true</emphasis></entry>
|
||||
<entry>whether or not to include the php file more than
|
||||
once if included multiple times</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
@@ -1666,6 +1674,13 @@ cell: 760-1234<br></programlisting>
|
||||
before hand.
|
||||
</para>
|
||||
<para>
|
||||
By default, php files are only included once even if called
|
||||
multiple times in the template. You can specify that it should be
|
||||
included every time with the <emphasis>once</emphasis> attribute.
|
||||
Setting once to true will include the php script each time it is
|
||||
included.
|
||||
</para>
|
||||
<para>
|
||||
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
||||
which will specify a template variable name that the output of
|
||||
<emphasis>include_php</emphasis> will be assigned to instead of
|
||||
@@ -2786,8 +2801,23 @@ OUTPUT:
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
cycle is used to cycle though a set of values. This makes it easy to
|
||||
alternate colors in a table, or even cycle through several of them.
|
||||
Cycle is used to cycle though a set of values. This makes it easy
|
||||
to alternate between two or more colors in a table, or cycle
|
||||
through an array of values.
|
||||
</para>
|
||||
<para>
|
||||
You can cycle through more than one set of values in your template
|
||||
by supplying a name attribute. Give each set of values a unique
|
||||
name.
|
||||
</para>
|
||||
<para>
|
||||
You can force the current value not to print with the print
|
||||
attribute set to false. This would be useful for silently skipping
|
||||
a value.
|
||||
</para>
|
||||
<para>
|
||||
The advance attribute is used to repeat a value. When set to true,
|
||||
the next call to cycle will print the same value.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the special "assign" attribute, the output of the
|
||||
@@ -2797,7 +2827,7 @@ OUTPUT:
|
||||
<example>
|
||||
<title>cycle</title>
|
||||
<programlisting>
|
||||
{* initialize the count *}
|
||||
{* initialize the values *}
|
||||
{cycle values="#eeeeee,#d0d0d0"}
|
||||
{cycle}
|
||||
{cycle}
|
||||
|
@@ -116,16 +116,16 @@
|
||||
<sect1 id="installing.smarty">
|
||||
<title>Installing Smarty</title>
|
||||
<para>
|
||||
Installing Smarty is fairly straightforward, there are a few things to
|
||||
be aware of. Smarty creates PHP scripts from the templates. This
|
||||
usually means allowing user "nobody" (or whomever the web server runs
|
||||
as) to have permission to write the files. Each installation of a
|
||||
Smarty application minimally needs a templates directory and a compiled
|
||||
templates directory. If you use configuration files you will also need
|
||||
a directory for those. By default these are named "templates",
|
||||
"templates_c" and "configs" respectively. If you plan on using caching,
|
||||
you will need to create a "cache" directory, also with permission to
|
||||
write files.
|
||||
Installing Smarty is fairly straightforward, there are a few things to be
|
||||
aware of. Smarty creates PHP scripts from the templates. This usually means
|
||||
allowing user "nobody" (or whomever the web server runs as) to have
|
||||
permission to write the files. Each installation of a Smarty application
|
||||
minimally needs a templates directory and a compiled templates directory.
|
||||
If you use configuration files you will also need a directory for those. By
|
||||
default these are named "templates", "templates_c" and "configs"
|
||||
respectively. "templates_c" needs to be writable by the web server user. If
|
||||
you plan on using caching, you will need to create a "cache" directory,
|
||||
also with permission to write files.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
|
@@ -1092,7 +1092,7 @@ function _generate_debug_output() {
|
||||
Function: _smarty_include_php()
|
||||
Purpose: called for included templates
|
||||
\*======================================================================*/
|
||||
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign)
|
||||
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once)
|
||||
{
|
||||
$this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type,
|
||||
$_smarty_php_resource);
|
||||
@@ -1100,7 +1100,11 @@ function _generate_debug_output() {
|
||||
if (!empty($_smarty_assign)) {
|
||||
ob_start();
|
||||
if ($_smarty_resource_type == 'file') {
|
||||
include_once($_smarty_php_resource);
|
||||
if($_smarty_once) {
|
||||
include_once($_smarty_php_resource);
|
||||
} else {
|
||||
include($_smarty_php_resource);
|
||||
}
|
||||
} else {
|
||||
eval($_smarty_php_resource);
|
||||
}
|
||||
@@ -1108,7 +1112,11 @@ function _generate_debug_output() {
|
||||
ob_end_clean();
|
||||
} else {
|
||||
if ($_smarty_resource_type == 'file') {
|
||||
include_once($_smarty_php_resource);
|
||||
if($_smarty_once) {
|
||||
include_once($_smarty_php_resource);
|
||||
} else {
|
||||
include($_smarty_php_resource);
|
||||
}
|
||||
} else {
|
||||
eval($_smarty_php_resource);
|
||||
}
|
||||
|
@@ -632,8 +632,10 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
$assign_var = $this->_dequote($attrs['assign']);
|
||||
|
||||
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var'); ?>";
|
||||
|
||||
$once_var = ( $attrs['once'] === false ) ? 'false' : 'true';
|
||||
|
||||
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>";
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user