XF 1.5 PHP 7.1 Template Error regarding strings with non-numeric values

SneakyDave

Well-known member
So I use this type of code in an admin template to display tabs of an addon's options...

Code:
    <ul id="OptionPanes">
    <xen:foreach loop="$renderedOptions" value="$_group">
        <xen:if hascontent="true">
        <li id="{$i}" class="profileContent">
        <fieldset class="optionList">
            <xen:contentcheck>
            <xen:set var="$i">{xen:calc '{$i} + 1'}</xen:set>
            <xen:foreach loop="$_group" key="$optionId" value="$renderedOption">{xen:raw $renderedOption}</xen:foreach>
            </xen:contentcheck>
        </fieldset>
        </li>
        </xen:if>
    </xen:foreach>

Since upgrading to PHP 7.1 I get a warning about $i not being numeric:
Code:
A non-numeric value encountered in /xxx/library/XenForo/Template/Abstract.php(279) : eval()'d code, line 101:100: $i = '';
101: $i .= ($i + 1);
102: $__compilerVar5 .= '

I assume to fix this, I just need to to initialize the string as a number. So I put this above the foreach:
Code:
        <xen:set var="$i">{xen:number 0}</xen:set>

That results in the same template error.

What am I doing wrong?
 
I think I got this fixed, changed the template to remove the calc and included the $i in the foreach

Code:
    <ul id="OptionPanes">
        <xen:foreach loop="$renderedOptions" value="$_group" i="$i">
            <xen:if hascontent="true">
                <li id="{$i}" class="profileContent">
                    <fieldset class="optionList">
                        <xen:contentcheck>
                        <xen:foreach loop="$_group" key="$optionId" value="$renderedOption">{xen:raw $renderedOption}</xen:foreach>
                        </xen:contentcheck>
                    </fieldset>
                </li>    
            </xen:if>
        </xen:foreach>
    </ul>
 
Back
Top Bottom