Menu

#46 section vars problems

v2.20
closed
5
2017-12-24
2009-01-30
Anonymous
No

as an example:
{section name=x loop=$vExample}
{if $vExample[x.index_prev].examplevar eq '0'}
prev
{/if}
{$vExample[x.index_prev].examplevar }
{/section}

Something like this returns an "unidentified token [x.index_prev].examplevar" error triggered from the "_compile_if" function for the line {if $vExample[x.index_prev].examplevar eq '0'} and if I change "x.index_prev" for "$templatelite.section.x.index_prev", I get a "parse error ... eval()'d code ..." error and the if section in the compiled php version looks like this:

_vars['vExample'][$this->_sections['x']['index']]['examplevar'] != $this->_vars['vExample'] $this->_sections['x']['index_prev']): ?>

when it should be:

_vars['vExample'][$this->_sections['x']['index']]['examplevar'] != $this->_vars['vExample'][ $this->_sections['x']['index_prev']]): ?>

This bug is for an error in the vars regex. But I've a basic level knowlegde of regex so I can't send a possible fix.

I hope you can fix this, or publish a patch.

There is an alternative for this, assigning the value to a new variable and then use that variable as the key for array, but that means to create more innecesary variables...
Example:
{assign var=idxprev value=$templatelite.section.x.index_prev}
{if $vExample[$idxprev].examplevar eq '0'}

Thanks for place an eye on this ;)

Discussion

  • Agustin Didiego

    Agustin Didiego - 2009-01-30

    Sorry, I register in SF before send this bug/issue.

     
  • Don Duvall

    Don Duvall - 2011-01-14

    Thank you for The feature, bug ticket. I have recently acquired this project and am looking into this. I am thinking about redesigning the compilers regex usage as it is using deprecated php functions. this will also remove the php4 support, and add object (class) usage in the templates.

     
  • Don Duvall

    Don Duvall - 2017-11-18

    Ticket moved from /p/templatelite/feature-requests/13/

     
  • Don Duvall

    Don Duvall - 2017-11-18
    • status: open --> pending
    • assigned_to: Don Duvall
    • Group: --> v2.20
     
  • Don Duvall

    Don Duvall - 2017-11-18

    This has been implemented, and will be included in the v2.20 release in January 2018.

    {section name=dog loop=$Dogs}
        {if $Dogs[dog.index_prev]->Name eq null}
            prev
        {/if}
        {$Dogs[dog.index_prev]->Name}<br>
    {/section}
    
    ----
    OUTPUTS:
    ----
        prev
            <br>
            Dogie0<br>
            Dogie1<br>
            Dogie2<br>
            Dogie3<br>
            Dogie4<br>
            Dogie5<br>
            Dogie6<br>
            Dogie7<br>
            Dogie8<br>
    
     
  • Don Duvall

    Don Duvall - 2017-12-24
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel