Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

resolving js in foreach stmt

I have 15 (give or take) committees, each one with its own mini-website, complete with index page and articles.

I want each committee mini-site to look exactly the same. I'd prefer to do it with one template, and structure each mini-site exactly the same.

Each committee home page (\committee\committee-x\index.html) has this event listing script:

{$ foreach article in (and  (after today)(keywordContains "event")(keywordContains "youth")) $}
{$ article.headline $}
{$ next $}

where "youth" is the name of this particular committee. The keyword and the subdirectory are the same: youth. The subdir is \committee\youth.

I figure if I can use a js to find the subdir, then I can drop that subdir into the foreach stmt to find "youth" events.

The js is:

var path = "";
var xx = document.location.href;
var yy = xx.substring(0,href.lastIndexOf("/"));
var zz = yy.substring(yy.lastIndexOf("/")+1,yy.length);

Is it possible for the foreach stmt to know the current subdir?

Is it possible to use this js in the foreach stmt?

Thanks :-)

Bob Bloom
Saturday, July 05, 2003

CityDesk scripting is run to build the pages from your articles and templates.  It, then is installed on your site when you publish.

Javascript runs inside the user's browser when they view a page.  So, if I understand you correctly, the answer to your question is no.

In CD v2 there are new features for scripting, one of which is "thisFolder".  Check out the documentation, and you might see how to do this without the js.

Also, check out Terry's tips (link is on the left of this page).  He's catagorized lots of information that has shown up on here, and your situation is pretty typical.  I think you'll find some examples

good luck!

Joel Goldstick
Saturday, July 05, 2003


Thanks for your post.

For an example of js in cd, check out

(thisFolder) is the answer *except* that it's possible that a committee's event is in another folder (eg, jointly run events). So I'm continuing my search. I'll post what I've found.

Bob Bloom
Saturday, July 05, 2003

I'm placing articles s.t. the (thisFolder) condition will work. Thanks!

Bob Bloom
Monday, July 07, 2003

*  Recent Topics

*  Fog Creek Home