Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

is there a {$ folder $} variable?

Is there a variable called {$ folder $}?

It would be helpful to construct a "where am I" navigational construct on the top of my pages.

The variable {$ folder $} would output the current subfolder the article is in.

Bob Bloom
Wednesday, May 21, 2003

It's a common request. Currently, no.

In the next version of the beta (beta 2, which will arrive in an hour or two) there is a new "thisFolder" feature which can be used to implement what you described.

Joel Spolsky
Wednesday, May 21, 2003

an hour or two... woo hoo.

www.marktaw.com
Wednesday, May 21, 2003

It's a double woo hoo.

tk
Wednesday, May 21, 2003

Thanks for adding this feature, Joel :-)

Bob Bloom
Wednesday, May 21, 2003

Joel,

* Does {thisFolder} work on subfolders so that I can list all articles in the entire site with one command?

* {thisFolder} and {thisArticle} aren't variables in my script that return html. They only resolve within CD script. So please create {$ thisFolder $} and {$ thisArticle $} to create the html for the folder name the article is in, and the article name of the current article.

Bob Bloom
Thursday, May 22, 2003

thisFolder does not include subfolders. But you CAN list all the files in your site in any folder with one command: {$ foreach x in (all) $}

There isn't a direct way to print the name of the current folder. That is because folder names are rather limited, they are usually short names and not user-friendly names, and you may want a hyperlink to an index file.

The best way to do this is to have an "index" file in every folder (you need one of these, anyway, in case people click on a link to the folder). Then use an extra field from the index file to put breadcrumbs to the current folder; this part is manual. Finally in all your templates use a loop like

{$ forEach x in (and (thisFolder) (fileName "index"))$}
{$ x.extra1 $}
{$ next $}

which will extract and print the breadcrumbs for the current folder automatically.

The "index" in each folder can use its own template where the body of the template does {$ forEach x in (thisFolder) $}. So you don't even have to write anything in the index body itself, just make sure that there is one in every folder and that it has the right template.

Joel Spolsky
Thursday, May 22, 2003

Joel:
> Then use an extra field from the index file to put breadcrumbs to the current folder; this part is manual.

What do you propose should be in the extra field?

Couldn't that be just a link to the headline of the index file instead of something in an extra field, like:
{$ forEach x in (and (thisFolder) (fileName "index"))$}
<a href="{$x.link$}">{$x.headline$}</a>
{$ next $}

Paul Iliano
Thursday, May 22, 2003

It depends how you want to do your breadcrumbs.

You might want to do something like

You are here > My Site > News > Local > Politics

where each of those things is a link to the index for the page in question.

Joel Spolsky
Thursday, May 22, 2003

> You are here > My Site > News > Local > Politics

Yes, that's exactly what I have in mind

> where each of those things is a link to the index for the page in question

Indeed, so back to my question: what is the value of using an extra field (perhaps I miss something), when we can simply link to the headline like:
{$ forEach x in (and (thisFolder) (fileName "index"))$}
<a href="{$x.link$}">{$x.headline$}</a>
{$ next $}

Paul Iliano
Thursday, May 22, 2003

Pity there's nothing like

thisFolder/*

I was looking foward to that.

It was the popular request in
an earlier thread.

Mark Major
Thursday, May 22, 2003

The {$.absLink$} returns the full path in html format Of course, there are no links and the path isn't parsed, but it's interesting!

Makes me think that a substring(string,starting_char,ending_char) function s/b in the next beta!

Bob Bloom
Friday, May 23, 2003

We also would need some functionality to show the current Folder and to select all items in the current and all subfolders (like $thisFolder$/*)
It would help us to build up our company-website with a complete automated navigation. Just create a new folder and put some items in the folder, and the navigation is generated dynamically.

Pierre Marsat
Monday, May 26, 2003

*  Recent Topics

*  Fog Creek Home