Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

feature wish


I've just tried a simple foreach loop like this

{$ foreach x in (folder"foldername") $}
{$ next $}

but for the first time my folder had sub-folders (till there I've only made loops on simple folders...)

to my disapointment (and supposing I didn't make any mistake, which is not proven...), this loop doesn't take subfolders in account,  so I suppose I have to put an "and" condition like this
(and (folder"foldername")(folder"foldername/subfolder1")(folder"foldername/subfolder2"))

But if I have to add one of these days a new subfolder, I have to verify all the loops I've written including subfolders. Ouch. too bad.

If you keep the default behavior like this in one of the future versions, could you add a syntax like (folder "foldername" including_subfolders) in the list of possible conditions ?

Or is there already an ability to include automatically subfolders, that I didn't discover ?

Vincent Bénard
Wednesday, January 30, 2002

I think this is what keywords are for. If you add the keyword "(blah)" and then do a foreach using (keyword_contains "(blah)") you can get all the files that match that keyword to appear.

Also, as I've learned, the (and...) condition doesn't work like that. You have to nest multiple ands to get more than two to string together, so the only acceptable and statement is:

(and (condition1) (condition2) )

However, (condition1) can be another "and" statement

(and (and (conditionx) (conditiony) ) (condition2) )

In summation: Use Keywords, Nest And/Or conditions.

Mark W
Wednesday, January 30, 2002

Keywords are an OK workaround, but it would be great if Vincent's idea was implemented in a future version of CityDesk. Having to remember to put keywords into every article is error-prone, whereas organising them into folders is intuitive.

BTW Vincent, I think you'll need to use "or" instead of "and". It's not possible for an article to be in folder1/subfolder1 *and* folder1/subfolder2, so you'll end up with an empty list to loop over.

Darren Collins
Wednesday, January 30, 2002

Hmmm. You say tomay-to, I say tomah-to. While I agree this is a nice to have, I don't think it's a defect in the software, IMHO this really is what keywords are for.

If implemented, I think the syntax should be something like (folder_include_sub "foldername").

Mark W
Wednesday, January 30, 2002

Nobody said it was a defect, and it's really not a tomay-to/tomah-to thing at all. Keywords and folders serve two different purposes. We're just suggesting an enhancement to the (folder "blah") feature.

Keywords are handy for doing things like building a list of all articles, from all over the site, that are about Microsoft (by putting "TICKER(MSFT)" in the Keywords field, for example). You don't care whether the articles are in the News, Investment or Sport folders. This is the purpose of Keywords described in the CityDesk documentation, and it works great for that.

Being able to iterate over all articles in a given folder, including subfolders, is a different thing entirely. This is useful, for example, for building tables of contents for topic indexes (e.g. latest News stories, latest Investment articles, etc). If I move an article to a different folder, it is automatically included in the new folder's index list, and removed from the old one. The user doesn't need to remember to fiddle around with Keywords for this to happen, so it removes a whole class of potential problems.

Remember, one of the target markets for CityDesk is people that don't have much technical knowlege, but manage content for a site that they got someone else to set up for them. I think adding this feature would help us set up sites for easy maintenance by these people. Besides, it isn't hard to add and wouldn't break CityScript's syntax (or any existing code).

Darren Collins
Wednesday, January 30, 2002

The "recurse subfolders" option was the first thing I wanted to have and didn't. Here's an example of what I needed it for:

I have a "Projects" folder, which has various sub-folders such as "Tools", "Libraries", etc. On the front page, there is a section where I list the ten most recently updated projects, regardless of sub-category. On the projects page, I list the projects by sub-category. I had to do the "or or or" trick to get this to work, but it would have been much easier and more flexible if I add folders in the future if the recurse subfolders option were possible.

Steve Anichini
Wednesday, January 30, 2002

I want new conditions something like this:

"This_folder" and

"This_folder" being the folder that contains the script referencing it.

I might also need: This_folder = "a specific foldername" if the script wasn't in the foder that I need to operate on.

That would make some very handy scripts more portable.

I forget the keywords, mispell the keywords and my colloborators may forget them too.  Don't get me wrong, I like and need the keywords.

Wednesday, January 30, 2002

I agree that these would be great features, and really adds depth and breadth to the CityDesk functionality.

Our site is a lot less linear than that, so we need keywords to put together pages of various things that cross folders. So while we might have a "news" folder and a "products" folder we want to be able to put together a "news" page, "products" page AND various pages for different markets - a US page with US products and news, support pages for the people who use the various products, etc.

Under these circumstances it's always difficult to decide which bucket to put things in - by region or by type or by audience? With CityDesk it doesn't really matter how you put these things together in the first place, it all gets pulled together "dynamically."

Regarding mis-spelled keywords, how about an auto-complete feature? This ought to clear that up.

Mark W
Wednesday, January 30, 2002

Darren wrote:

"BTW Vincent, I think you'll need to use "or" instead of "and". It's not possible for an article to be in folder1/subfolder1 *and* folder1/subfolder2, so you'll end up with an empty list to loop over"

Thank you Darren, you're right.
The and/or confusion is very common especially in the use of the advanced functionnalities of search engines that require booleans expressions. So I discover it may be confusing in citydesk scripting too.

If this part of the documentation (using and, or... and nested conditions) was developped, it would help.

Vincent Bénard
Thursday, January 31, 2002

This is an interesting discussion ... I need to figure out how we could implement folder_and_subfolders. It's one of those things that shouldn't be hard to implement, but it happens to be hard, because of the nature of SQL. (don't ask). Nothing is impossible, it just happens to be dreadfully harder than you would think!

I also want to fix the limitation of "and" and "or" so they can take more than 2 operands. That's just a silly limitation...

Joel Spolsky
Friday, February 1, 2002

Joel says "...but it happens to be hard, because of the nature of SQL. (don't ask). Nothing is impossible, it just happens to be dreadfully harder than you would think!"

Does Jet/SQLServer/Access not support START WITH and CONNECT BY? Sheesh.

Austin Ziegler
Saturday, February 2, 2002

No... all those cool tree/hierarchical features are are Oracle extensions.

Joel Spolsky
Saturday, February 2, 2002

Back to the keywords thing:

I think I'd enjoy a "View keywords" feature and a way to select keywords from a list on the properties view.  Maybe one of items in the keyword selection list is "add new keyword."

Can anyone think of a script that would list all the keywords?

Correct keywords are going to be critical to some sites even if you solve the this_folder problem.

Saturday, February 2, 2002

*  Recent Topics

*  Fog Creek Home