← Back to team overview

phpdevshell team mailing list archive

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

 

PHPDevShell does not use the caching feature of Smarty, it is very
strange that your Smarty pages are not recompiled immediately. To save
load times Smarty compiles documents that changes. However,  it is
suppose to do that recompile on changes.

I will look into this.

-- 
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