Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

List Index Files in Several Folders

I'm looking for a way to list all the index.html articles in the first level of folders.  Has anyone tried this before?  Here's a quick example:

Site Root
  Company
      index.html
      locations.html
      management.html
  Products
      index.html
      Product Group 1
        index.html
        Product_A.html
        Product_B.html
      Product Group 2
        index.html
        Product_Y.html
        Product_Z.html
  News
      index.html
      archive.html

I'd like to list using a loop of some sort the index.html files under the folders Company, Products and News but not the ones under Product Group 1 & 2.

Any ideas?

PRyan
Monday, October 25, 2004

Off the top of my head, one of these might work:

<div>
{$foreach x in ( and (filename "index") not (filename "Product Group 2/index" ) )  $}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

Or,
<div>
{$foreach x in ( and (filename "index") not (folder "Product Group 2/" ) )  $}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

Or, add the keyword Ignore to the index files you want to ignore and do this:

<div>
{$foreach x in ( and (filename "index") not (keywordContains "Ignore" ) )  $}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

Or, add the keyword Navigation to the index files you want to include and do this:

<div>
{$foreach x in ( and (filename "index") (keywordContains "Navigation" ) )  $}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

David Burch
Monday, October 25, 2004

Sorry,

Didn't read your post closely enough:  I think keywords is the only thing to do with the current version of CityScript.

David Burch
Monday, October 25, 2004

You don't want to "mix" the actual indexes, right? Just have one index followed by the next?

I'm having a hard time visualizing what you want. Do you have a reference URL that's more or less doing what you want?

Scott McDonald
Monday, October 25, 2004

<div>
{$foreach x in
(and (filename "index")
        (not (or (folder "Products/Product_Group_1")
                    (folder "Products/Product_Group_2")
                )
        )
)
$}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

David Burch
Monday, October 25, 2004

The above example works but, seriously, if the site is small I would just the links in an article using normal mode, set the template as none, and include the navigation scheme where you want it.

David Burch
Monday, October 25, 2004

Better use /* in case you add more subdirectories later.
You can add more folders to the or section to exclude them.

<div>
{$foreach x in
(and (filename "index")
        (not (or (folder "Products/Product_Group_1/*")
                    (folder "Products/Product_Group_2/*")
                )
        )
)
$}
<a href="{$x.link$}">{$x.headline$}</a><br />
</div>

David Burch
Monday, October 25, 2004

Agree with David here, that unless you're planning to add pages at a rapid clip that it would be more flexible to add this index as a piece of static HTML. If you want to feature this custom index on more than one page then make it a variable.

But I suspect that this may be a case where making this index dynamically-generated AND work the way you want is not worth the effort. As powerful as CityScript is -- and it IS pretty powerful despite some complaints to the contrary -- trying to use it for every aspect of your site is not always wise or practical.

Scott McDonald
Monday, October 25, 2004

Thanks for the help!

PRyan
Friday, October 29, 2004

*  Recent Topics

*  Fog Creek Home