← Back to team overview

phpdevshell team mailing list archive

[Bug 687603] Re: Template file generating error for nested {foreach} loops

 

Ok Adding, 2 new settings, the one will force the system to compile on
every page load, this is only for when site is not in production, as
soon as it goes into production force compile will be disabled.

-- 
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/687603

Title:
  Template file generating error for nested {foreach} loops

Status in Open Source PHP RAD Framework with UI.:
  New

Bug description:
  Per Smarty documentation, foreach loops can be nested.

Assume an array as follows in the controller:
$RESULTS = array('1' => array('A','B'), '2' => array('C','D'), '3' => array('E','F') );
$view = $this->factory('views');
$view->set('RESULTS', $RESULTS);
$view->show();

This .tpl file works (no nested foreach):
<table>
    {foreach $RESULTS as $x}
        <tr>

                <td>{$x}</td>

        </tr>
    {foreachelse}
        No items found
    {/foreach}
</table>

This one does not:
<table>
    {foreach $RESULTS as $x}
        <tr>
            {foreach $x as $y}
                <td>{$x}:{$y}</td>
            {/foreach}
        </tr>
    {foreachelse}
        No items found
    {/foreach}
</table>

The above generated nested foreach loop give the following error:
Syntax Error in template "/home/mydomain/portal/plugins/phpYAerpContacts/views/add-new-contact.tpl" on line 14 " {/foreach} " unexpected closing tag





References