diff --git a/NEWS b/NEWS
index 4ecbc1a4..02f91866 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+ - added "once" attribute to php_include (Monte)
+
Version 2.1.1
-------------
- added cycle function. (Monte)
diff --git a/Smarty.class.php b/Smarty.class.php
index c672fbef..c08832c4 100644
--- a/Smarty.class.php
+++ b/Smarty.class.php
@@ -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);
}
diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php
index 3beb15c8..61f80557 100644
--- a/Smarty_Compiler.class.php
+++ b/Smarty_Compiler.class.php
@@ -632,8 +632,10 @@ class Smarty_Compiler extends Smarty {
}
$assign_var = $this->_dequote($attrs['assign']);
-
- return "_smarty_include_php($attrs[file], '$assign_var'); ?>";
+
+ $once_var = ( $attrs['once'] === false ) ? 'false' : 'true';
+
+ return "_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>";
}
diff --git a/TESTIMONIALS b/TESTIMONIALS
index 95b02be8..c9e6d985 100644
--- a/TESTIMONIALS
+++ b/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
diff --git a/docs/designers.sgml b/docs/designers.sgml
index 1eec5db7..eef0017d 100644
--- a/docs/designers.sgml
+++ b/docs/designers.sgml
@@ -1637,6 +1637,14 @@ cell: 760-1234<br>
n/a
The name of the php file to include
+
+ once
+ boolean
+ No
+ true
+ whether or not to include the php file more than
+ once if included multiple times
+
assign
string
@@ -1666,6 +1674,13 @@ cell: 760-1234<br>
before hand.
+ 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 once attribute.
+ Setting once to true will include the php script each time it is
+ included.
+
+
You can optionally pass the assign attribute,
which will specify a template variable name that the output of
include_php will be assigned to instead of
@@ -2786,8 +2801,23 @@ OUTPUT:
- 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.
+
+
+ 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.
+
+
+ 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.
+
+
+ The advance attribute is used to repeat a value. When set to true,
+ the next call to cycle will print the same value.
If you supply the special "assign" attribute, the output of the
@@ -2797,7 +2827,7 @@ OUTPUT:
cycle
-{* initialize the count *}
+{* initialize the values *}
{cycle values="#eeeeee,#d0d0d0"}
{cycle}
{cycle}
diff --git a/docs/getting-started.sgml b/docs/getting-started.sgml
index cb48500d..ba3fa2c5 100644
--- a/docs/getting-started.sgml
+++ b/docs/getting-started.sgml
@@ -116,16 +116,16 @@
Installing Smarty
- 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.
Technical Note
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index c672fbef..c08832c4 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -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);
}
diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php
index 3beb15c8..61f80557 100644
--- a/libs/Smarty_Compiler.class.php
+++ b/libs/Smarty_Compiler.class.php
@@ -632,8 +632,10 @@ class Smarty_Compiler extends Smarty {
}
$assign_var = $this->_dequote($attrs['assign']);
-
- return "_smarty_include_php($attrs[file], '$assign_var'); ?>";
+
+ $once_var = ( $attrs['once'] === false ) ? 'false' : 'true';
+
+ return "_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>";
}