Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Conditional Content

I'd like to be able to throw a switch and get different articles included when I publish, but I'm not interested in duplicating articles so that I can use audiences. I'm thinking that the combination of keywords and variables would do the trick. Has anyone done this before?

Chris Sells
Monday, October 7, 2002

What kind of switch exactly?

How about just having different index pages that use different keywordContains rules in the foreach?

Joel Spolsky
Monday, October 7, 2002

What I'm after is building two CDs and a web site from a single cty file. The problem I'm having is that some articles go into one CD and the web. Using audiences, I can get articles into Everyone or into CD1, but I can't get an article into CD1 *and* Web w/o duplicating it.

I could using conditionals in the for statement that builds the indexes, but the content still gets generated, even if it isn't listed, which is a problem for a browseable CD. Of course, that's also a problem for files as a whole, e.g. a download that goes with a particular article shouldn't be "generated" if the article isn't generated.

I've decided that what I'd really like to do is tag an article with more than one audience instead of having to copy-paste. I'd also like to tag other files with zero or more audiences.

Chris Sells
Tuesday, October 8, 2002

Chris, if you look at the weblog download (check ) and specifically look at the article Book Reviews in the NavLinks folder you will find some HTML and cityscript which looks like this:

{$foreach b in (keyword_contains "book(bridge)")$}

You can have more than one keyword in an article, and that may be more of what you actually need to determine for which "audience" an article will be published.

Charles Reich
Tuesday, October 8, 2002

Charles, that works for the index page content, but the actual articles will still get published even if they don't appear on the index page.

So if Chris was creating a 'lite' CD and a 'pro' CD of his content, all of the 'pro' content would still be present in the 'lite' CD. It would be a little more difficult for users to find it, since it wouldn't appear on the index pages, but you're still giving them content they haven't paid for.

I think what Cris wants is an Audience feature that allows articles to apply to multiple audiences, so that he can tag his articles as 'pro', 'lite', 'web' or any combination of those.

At present, you can only tag an article as being for one audience or for all audiences. So you can't have something that's for the 'lite' version and the 'pro' version but not the 'web' version.

Darren Collins
Tuesday, October 8, 2002

How about playing with publication dates? If the content is in concentric rings -- web includes all, pro includes only lite -- then the lites get the earliest date, pro gets a mid-date and web gets the late date. Publish by date.

Amos Satterlee
Tuesday, October 8, 2002

That's a creative solution, Amos!

Darren Collins
Wednesday, October 9, 2002

Great Amos!

Here is what I kept thinking of:

A variable called "switchkeyword" that I could change according to what I was publishing.

Then scripts that looked like this

{$for each x in (keword_contains "{$.switchkeyword$}"$}

I don't think this works though.

Wednesday, October 9, 2002

>Then scripts that looked like this
>{$for each x in (keword_contains "{$.switchkeyword$}"$}
>I don't think this works though.

You're correct, this doesn't work - and how I wish it did!

As far as I can see, CD can't cope with expanding out the keyword from a variable. I'd really like to be able to do this, so hope that someone can prove me wrong!

Andy Hardy
Friday, October 11, 2002

*  Recent Topics

*  Fog Creek Home