Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Nested ForEach???

"Nested ForEach statements cannot use same variable name. (This might also be caused if you have a foreach statement in an article that includes itself) (\testindex.html:1928)"


I got this error. Here's the section of my testindex.html tha changed:

{$foreach 1 x in (filename "homepage news (the center column)") SortAscendBy .fileddate $}{$x.body$}{$next$}


And here's the foreach loop in "homepage news (the center column)"

            <table border="0" cellspacing="0" cellpadding="2">
              {$foreach 5 x in (or (folder "news") (keyword_contains "(news)")) SortDescendBy .fileddate $}
              <tr>
                <td class="newsheadline">{$x.headline$}</td>
              </tr>
              <tr>
                <td class="newsteaser">{$x.teaser$}</td>
              </tr>
              <tr>
                <td>
                  <hr size="1">
                </td>
              </tr>
              {$next$}
            </table>


Any ideas? "homepage news..." is in a folder /indexfiles/includes not /news. Nor does it contain a keyword (news).

Mark W
Thursday, March 21, 2002

Oh I figured it out. If I do a {$foreach x$} I need to make the nested one {$foreach y$}.

Mark W
Thursday, March 21, 2002

like you said :)

Joel Spolsky
Thursday, March 21, 2002

*  Recent Topics

*  Fog Creek Home