diff --git a/NEWS b/NEWS index 96b6534b..f3dd69e5 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,9 @@ - - split out compiling code to separate class for faster - template execution time (Monte) - - added unregister_modifier, documented (Monte) - - added unregister_function, documented (Monte) - - added fetch function, documented (Monte) - - added math function, documented (Monte) + - added 'first' and 'last' section properties. (Andrei) + - split out compiling code to separate class for faster template execution + time (Monte) + - added and documented unregister_modifier() and unregister_function() API + calls. (Monte) + - added and documented 'fetch' and 'math' functions. (Monte) - added ability to index looped variables by section properties, e.g. $foo.index_prev/bar. (Andrei) - added index_prev and index_next section properties. (Andrei) diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index fcbec211..8c294f3f 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -491,6 +491,8 @@ function _compile_section_start($tag_args) $output .= "{$section_props}['rownum'] = {$section_props}['index'] + 1;\n"; $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - 1;\n"; $output .= "{$section_props}['index_next'] = {$section_props}['index'] + 1;\n"; + $output .= "{$section_props}['first'] = ({$section_props}['index'] == 0);\n"; + $output .= "{$section_props}['last'] = ({$section_props}['index'] == {$section_props}['loop']-1);\n"; $output .= "?>"; diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index fcbec211..8c294f3f 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -491,6 +491,8 @@ function _compile_section_start($tag_args) $output .= "{$section_props}['rownum'] = {$section_props}['index'] + 1;\n"; $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - 1;\n"; $output .= "{$section_props}['index_next'] = {$section_props}['index'] + 1;\n"; + $output .= "{$section_props}['first'] = ({$section_props}['index'] == 0);\n"; + $output .= "{$section_props}['last'] = ({$section_props}['index'] == {$section_props}['loop']-1);\n"; $output .= "?>";