Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

keyword in foreach not possible ?

hi,

I am trying the followin code to get a list of all files with a keyword that I put in the actual file as extra1 = uberuns.

{$ .extra1 $}  returns ueberuns as the searching keyword. but


{$foreach x in (and folder "Articles/*"  keywordContains "{$.extra1$}"  ) (not (filename "index"))) $}
....
{$next$}

it's it possible to use "{$.extra1$}"  in the foreach ?
when I put in "ueberuns" in the foreach it works correct. Any idea ?

Bernd
Monday, January 19, 2004

I don't think this will work, due to CityDesk's variable expansion order.  Why not put the extra1 keyword in the Keywords field?

BTW I agree CD scripting should be more flexible and powerful.

David Burch
Monday, January 19, 2004

Hi Bernd,

I think there are some brackets missing. Give it a try with (I haven't tested it):

{$foreach x in
    (and
        (folder "Articles/*") 
        (keywordContains "{$.extra1$}")
        (not (.filename "index"))
    )
$}
....
{$next$}

For explanation: {$.xxxx$} variables will be expanded everywhere. All expressions combined with the 'and' have to be in seperate conditions, thus CD can decide it's true or false. In front of 'filename' a dot (.= was missing. Do you want to exclude the current document or a article found with the name 'index'? With the later an 'x' would be missing, too.

BTW, why is the keyword also in the 'index' file once you know, you don't want it listed. To have a really universal script in CD, restrict yourself to 'switches', which are easy. Switches combined by keyword, location and/or filename are hard to remember, after running a web-site for 12 month and more... (I experienced it myself and had to start from new, because my understanding nowadays was different to 2002...8-))

Have a nice try, Steffen

Dr. Steffen Steinhäuser
Tuesday, January 20, 2004

hi,

it realy looks like the .extra is't not interpreted when it is between "". I think I have to write serveal template to get the multi-level navigation. Not realy nice but I am run out of time now. thanks everbody for the support

Best regards Bernd

Bernd
Tuesday, January 20, 2004

In CD 2.0, you can't use variables or article fields in the conditional part of a foreach statement.

I'm sure it'll come in the next version of CityDesk - such a feature would make CityScript capable of much more. A lot of people have asked for it.

Darren Collins
Tuesday, January 20, 2004

I've got a similar problem.  I want to replace a small XML database that we use with Ciry Desk to show news articles in a descending date order.  However, we then have a form with one field that allows the user to input a keyword (currently the keyword is something in the title of the article) and the page refreshes to show articles that match that keyword.  It seems as though CD can't do that, am I right ?

Jim Blair
Monday, January 26, 2004

*  Recent Topics

*  Fog Creek Home