Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Problem with articles and folders having same name

The following instructions can be used to demonstrate the problem I have just seen (using Beta 5):

Create a folder called Products and inside that another folder called Prod1. Also create an article in the Products folder called Prod1. In the Prod1 article I want to list all articles in the Products/Prod1 folder, using

{$ foreach x in (folder "Products/Prod1" $}
{$ x.header $}
{$ next $}

However this does not produce any results.

I assumed that this was a problem with nested folders, so tried moving my Prod1 folder to the root and changing the reference in the foreach. Now it works fine.

I next moved my Prod1 folder back to the Products folder, but it gets silently renames to Prod1_2 in the process. When I try to rename it, I get a "Duplicate Name" error. I change the reference in the foreach loop to reference "Products/Prod1_2" and suddenly, my I can see my list of articles.

So, to recap:

1. It is possible to create an article with the same name as a folder, but creating a folder with the same name as an article gives an error.

2. If you have a folder with the same name as an article, then a for loop of articles in the folder does not yield any results.

Hope this helps,

Neil Attard

Neil Attard
Friday, November 30, 2001

Neil -

The loop you wrote
{$ foreach x in (folder "Products/Prod1" $}
{$ x.header $}
{$ next $}

has two small bugs - no ")" at the end of the foreach statement, and, there's no such thing as a "header" field. When I fixed these two everything worked fine. (Also in your repro steps you did not mention putting any articles inside Prod1, but I assume that you did that!)

Since articles are not published using their own name (but instead get fog0000000000.html type names), it's OK to have an article with the same name as a folder, although I guess some of the renaming-validation code is being stricter than necessary.

Joel Spolsky
Friday, November 30, 2001

Sorry for the careless typos in my previous message. I did not have the CityDesk software running at the time and so "remembered" the problem. However, the problem IS a real one (at least for me). Those typos did not exist in the actual site.

I will try this again from the starter site and record my findings. Here goes:

1. Create a new article in the Articles folder - leave its name "New Article" for now.

2. Create a new folder in Articles - change its name to Prod1.

3. Rename the new article, "Prod1".

4. Create two new articles ("New1" and "New2") in the folder Prod1. Edit them and make sure that they have Headlines - "New1" and "New2".

5. Edit the Prod1 article and type the following in the Normal View:

{$ foreach x in (folder "Articles/Prod1") $}
{$ x.headline $}
{$ next $}

6. Preview the Site

- The main page shows 4 articles, "Getting Started...", "Prod1", "New1" and "New2".

- Choose the Prod1 article. It shows no articles.

7. Change the name of the Prod1 article to Prod2. Preview the site again.

- This time, it all works as it should.

Let me know if you would like me to send you the site.

Best Regards,

Neil Attard

Neil Attard
Friday, November 30, 2001


Thanks for the report.  I have verified the behavior you are seeing.

As a workaround, create the article AFTER you create the folder.  If you already have the article, just open it up, copy the text, delete the article, recreate it, and paste in the text.  I believe this should fix the problem, but as I said in the other thread, I think for what you may be trying to do, you'd be better off creating an index.html file there instead of the article.

Michael Pryor
Friday, November 30, 2001

*  Recent Topics

*  Fog Creek Home