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}