Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Using variables in foreach/keywordcontains

Working on my first 'not for profit' site. I really appreciate all the advice that flows through this forum - hopefully you can help.

I have 3 basic article styles - with or withour a right hand sidebar. The article styles are
1. simple straight article.
2. multi article where each article is made up of several sub 3. articles stored separately
photo albom - really a special version of 2.

I don't want the end user to use the simplicity of the CD article database and so I was looking to store all the multipart articles in a single directory "MP" with a unique keyword identifying the subarticle group membership.

then the main article would have the logic to use the extra1 field to hold the keyword id as in :-

{$ foreach x in (and(folder"MP")(keywordcontains"{$.extra1$}"))$}
{$x.headline$}
{$x.body$}
{$ next $}

the logic fails - why - I seem to be breaching a CDscript rule

Any advice most welcome

Martyn Bryan
Friday, September 05, 2003

Why not put the keywords in the keywords field instead of extra1? I use keywords (in round brackets) a lot and it works fine.

Jorgen Brenting
Friday, September 05, 2003

sorry - keyword is in the keyword field of the subarticle. The extra1 field is in the main article - identifying which sub articles to 'collect' into the compound document

Martyn Bryan
Friday, September 05, 2003

I wonder whether it doesn't like this:
(keywordcontains"{$.extra1$}")

However, I would create a subfolder for each article.  They you can loop on the articles in the subfolder instead of using keywords.

Joel Goldstick
Friday, September 05, 2003

I don't think CD likes variables in loops (sigh).

An alternative might be to put both main and subarticles into the same dedicated directory and let it loop using (thisFolder).  That way you should be able to use one and the same script across all main articles.

Vic
Friday, September 05, 2003

*  Recent Topics

*  Fog Creek Home