Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

forEach-Statement: isfirst/islast function?...

Hello
I'd like to generate the following pattern of Links:

Welcome - About - Content - Guestbook

It's no problem to get the links with the following script but this adds an extra hyphen after the 'Guestbook' entry:

{$foreach x in (keyword_contains "index")$}
<A " href="{$x.link$}">{$x.extra1$}</A> -
{$next$}

This generates:
Welcome - About - Content - Guestbook -

How do I generate the list correctly? I think I need something like {$ if not( islast x) $} - {$end$}
or {$ if nonblank (x.nextOccurence) $}

Thanks for help, haven't found a related topic in the forum yet.
Stephan

Stephan Germain
Thursday, October 16, 2003

Stephan :re This generates:
Welcome - About - Content - Guestbook -

Try the following:

{$foreach x in (keyword_contains "index")$}
- <a " href="{$x.link$}">{$x.extra1$}</a>
{$next$}

The only change I made to your code is the *placement* of the "-"

That should work.

David Mozer
Thursday, October 16, 2003

Thanks for your suggestion... but... that generates

- Welcome - About - Content - Guestbook

Hmm...

Stephan Germain
Thursday, October 16, 2003

Use the {$between$} function.  Check out "Text Between Items in a Loop" in the Help file.

Amos
Thursday, October 16, 2003

Great, that helps!
Thank you

Stephan Germain
Thursday, October 16, 2003

For the lazy (like me), the code using {$between$} looks something like this:

{$foreach x in (keyword_contains "index")$}
<a href="{$x.link$}">{$x.extra1$}</a>{$between$} -
{$next$}

Martha
Thursday, October 23, 2003

*  Recent Topics

*  Fog Creek Home