From 54609949065afb2014a71837b1b040bd8b16c669 Mon Sep 17 00:00:00 2001 From: andrey Date: Mon, 22 Jan 2001 15:15:49 +0000 Subject: [PATCH] Fixed bug that wouldn't let you do specify non-array values for 'loop' attribute. --- Smarty.class.php | 2 +- demo/templates/index.tpl | 2 +- libs/Smarty.class.php | 2 +- templates/index.tpl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Smarty.class.php b/Smarty.class.php index 20a8f8d4..cf673a14 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -568,7 +568,7 @@ class Smarty foreach ($attrs as $attr_name => $attr_value) { switch ($attr_name) { case 'loop': - $output .= "{$section_props}['loop'] = count($attr_value);\n"; + $output .= "{$section_props}['loop'] = is_array($attr_value) ? count($attr_value) : $attr_value;\n"; break; case 'show': diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index 17c86bcb..ab5cf4fb 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -15,7 +15,7 @@ the value of $SCRIPT_NAME is {$SCRIPT_NAME} hello, my name is {$Name|upper} My interests are: -{section name=outer loop=$FirstName} +{section name=outer loop=2} {if %outer.index% is odd by 2} {%outer.rownum%} . {$outer/FirstName} {$outer/LastName} {else} diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 20a8f8d4..cf673a14 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -568,7 +568,7 @@ class Smarty foreach ($attrs as $attr_name => $attr_value) { switch ($attr_name) { case 'loop': - $output .= "{$section_props}['loop'] = count($attr_value);\n"; + $output .= "{$section_props}['loop'] = is_array($attr_value) ? count($attr_value) : $attr_value;\n"; break; case 'show': diff --git a/templates/index.tpl b/templates/index.tpl index 17c86bcb..ab5cf4fb 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -15,7 +15,7 @@ the value of $SCRIPT_NAME is {$SCRIPT_NAME} hello, my name is {$Name|upper} My interests are: -{section name=outer loop=$FirstName} +{section name=outer loop=2} {if %outer.index% is odd by 2} {%outer.rownum%} . {$outer/FirstName} {$outer/LastName} {else}