Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Cannot use [] for reading #62

Closed
mazzucode opened this issue Jun 22, 2015 · 1 comment
Closed

PHP Fatal error: Cannot use [] for reading #62

mazzucode opened this issue Jun 22, 2015 · 1 comment

Comments

@mazzucode
Copy link

Hi,

I made an upgrade from Smarty 3.1.21 to 3.1.27, after this i am getting this error in some templates:

PHP Fatal error: Cannot use [] for reading in /home/conquist/views_c/83c15fae7d6abe30de328afde91cc87c27947c90_0.file.Imovel.view.tpl.php on line 387

The line 387 starts with:

<?php if ((isset($_smarty_tpl->tpl_vars['__foreach_info']->value[]) ? $_smarty_tpl->tpl_vars['__foreach_info']->value[] : null) < 4) {?>
    <li><h4><?php echo ('- ').($_smarty_tpl->tpl_vars['info']->value);?>
</h4></li>
<?php }?>`

I am not seeing how to solve this issue. Anybody can help me please?

Edit 1

The original code is:

{foreach $dadosImovel.nomes_diferenciais as $info}
    {if $smarty.foreach.info < 4}
        <li><h4>{'- '|cat:$info}</h4></li>
    {/if}
{/foreach}
@uwetews
Copy link
Contributor

uwetews commented Jun 27, 2015

$smarty.foreach is a special Smarty variable for named Smarty 2 style {foreach} tags to access special properties.
See http://www.smarty.net/docsv2/en/language.function.foreach.tpl and example 7.10.

$smarty.foreach.info in your case is not valid.

I think you did mean {if $info < 4}.

<li><h4>{'- '|cat:$info}</h4></li> could be simplified like

<li><h4>- {$info}</h4></li>

@uwetews uwetews closed this as completed Jun 27, 2015
think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
Merge release-2.0.7.1 into master branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants