Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Limited conditions

I'm using extra2 to act as a category field since this obvious field doesn't exist and I want to generate lists of articles on subcategories of each category.
So I want to do something like:
If category is "Fruit" then do a for next loop to produce list of all content files related to the current subtopic of fruit that I'm processing the page for.
Any ideas?
I just can't get how come I can' tdo a condition x = y and why aren't such basic boolean things there in the first place?

Richard Wood
Tuesday, October 29, 2002

You can use folders as categories. Put all your 'fruits' in folder 'Fruit' and do a:

{$foreach x in (and (folder "Fruit") (not(keyword_contains "(indexpage)")))  SortAscendBy .headline$}
{$x.headline$}
{$setDateTimeFormat "Danish" "dd MMM, yyyy" "hh:mm"$}{$x.filedDate$}
{$x.teaser$}{$ if  nonblank x.extra1 $} {$x.extra1$} {$ endif $}
{$next$}

Just change the Danish time format to suit your local style.

Jorgen Brenting
Wednesday, October 30, 2002

this has been discussed for long in the forum.

The "folder" condition is a correct workaround but doesn't replace a real categorization system.

In many sites, you need to use several categorization axes:

for instance
thema/subthema (e.g: water / water cleaning)
type / Subtype ( e.g: technical info/white paper)
concerned area (e.g worldwide or france/southwestern )
...

folders allow only to handle one of these axes. keywords could handle a second one, but a real categorization system would be a real improvement.


vincent bénard
Wednesday, October 30, 2002

You can have all the subcategories you want with keywords. Put as many category keywords in each page as you need. Put each keyword in parentheses and put code like this in the page to show the categories:

Fruits
{$foreach x in (and (folder "Fruit") (keyword_contains "(Fruit)")) SortAscendBy .headline $} {$x.headline$}
{$x.teaser$}
{$next$}

Bananas
{$foreach x in (and (folder "Fruit") (keyword_contains "(Bananas)")) SortAscendBy .headline $} {$x.headline$}
{$x.teaser$}
{$next$}

and so on and on as long as you like with apples, peaches and you name it.

Jorgen Brenting
Wednesday, October 30, 2002

True Jorgen, but what when I want to loop through folders recursively?

Just say I offer 3 food types - fruit, vegetable and deli items.

I want something to generate an index page that runs through each folder of food types and then each subfolder of foods. Your solution works, provided you nominate the subfolder keywords.

However, this is a little bit of a problem in that I always have to come back and hard code what fruit I have. This does not allow for dynamic content management.

It would be *great* if I could do a loop like this on the home page or products page

//outer loop

{$foreach x in (folder "Food Types") SortAscendBy .headline $}

    //inner loop

    {$foreach f in (keyword_contains +{x}+ )}

    {$f.headline$}

    {$next$}

{$next$}


All I have to do is make sure that someone creating a new fruit page adds the fruit keyword to the document - no need to bother the code monkey.

Now, I can only list the categories on the front page and THEN the user has to click again to see the offering for that category*.

*said having committed the cardinal sin of not reading every post on the news board first to see if there is a way of doing it.

Patrick FitzGerald
Monday, November 04, 2002

You put all your articles (fruit, vegetable and deli items) in one folder named Fruit. Each article have several keywords according to predefined subgroups. Now you can have each article's headline or whatever show up in several places on your index page. This way you don't have to loop through folders recursively.
I have used this system here (sorry about the language): http://www.baskerville.dk/Depottest/Serier/Dansk.html
The headlines with yellow background describe the subgroups. Each new article will fit in automatically in as few or as many subgroups as you (or your authors) want. To the user it will look the way you describe.
This is not what you ask for exactly, I know, but it's a usable workaround. Of course the code monkey might have to put in a new subgroup now and then but what are monkeys for anyway?

Jorgen Brenting
Tuesday, November 05, 2002

*  Recent Topics

*  Fog Creek Home