1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest The way <xen:set> is compiled

Discussion in 'Closed Suggestions' started by Robbo, Nov 14, 2011.

  1. Robbo

    Robbo Well-Known Member

    The way <xen:set> is compiled sets the var specified to '' straight away. Is there any chance a $compileVar can be used instead and after the contents of the <xen:set> set it to whatever var was?

    The reason for this is I couldn't work out why this code was giving me 2 every time.
    <xen:set var="$row"><xen:if is="{$row} == 2">1<else />2</xen:if></xen:set>
    Using a temp var while processing the contents would mean you could use the var within those contents if it exists and be handy for things like my example. I have to do this instead...
    <xen:if is="{$row} == 2"><xen:set var="$row">1</xen:set><xen:else /><xen:set var="$row">2</xen:set></xen:if>
    More code, harder to read etc.

    Just sharing my annoyance and what would have stopped it from occurring.
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    For one, your original syntax is invalid seen as you never close the var="" variable.
  3. Robbo

    Robbo Well-Known Member

    That was a typo when making this post. Regardless of it missing it won't work anyway because of how it is compiled. It will always be set to 2 as $row will equal ''.
  4. Robbo

    Robbo Well-Known Member

    Having this issue again with something... forgot about it and now realize this still happens. I don't see why the compiler can't do if (!isset($var)) $var = ''; to init instead. I am having to store a temp var for it now...
  5. Robbo

    Robbo Well-Known Member

  6. Adam Howard

    Adam Howard Well-Known Member

    I can confirm this bug (explains A LOT actually)

    Well done, Robbo

Share This Page