Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

CityScript Blocked

I'm trying to get clever with CityScript.  I want to create "you might also like" links to all other articles that have the current article's headline as a keyword.  I want to do this to each of over 500 articles, so I'm looking for some code to put in a template.

I have a variable called thisArticle that contains:

<script language="javascript">
var tmp = "{$ foreach 1x in (thisArticle ) $} {$x.headline$} {$ next $}";
document.write(tmp);
</script>

I'm trying to use the javascript generated text as input to the keywordContains condition of a loop, like this.

{$ forEach x in (keywordContains "{$.thisArticle$}") $}
{$x.headline$}
{$next$}

Can anyone think of a way to make this work?

David Burch
Friday, August 13, 2004

Javascript gets executed in the browser, whereas CityScript is interpreted when your site is published (i.e. long before it hits a browser). So there's no way that CityScript can use a value calculated by Javascript.

Darren Collins
Sunday, August 15, 2004

Okay, I guess what I need is the contents of thisArticle and thisFolder exposed as variables  (Feature request).

David Burch
Thursday, August 19, 2004

*  Recent Topics

*  Fog Creek Home