Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Next and Previous article variables

I might just be missing this somewhere, but I would like to maintain my "next / previous" links that I put at the top and bottom of my pages. Variables for this would be useful.


Maury Markowitz
Friday, December 7, 2001

I was just thinking this last night.  Of course, this could be a tricky thing to implement.

Does the Next link point you to the next article in the list of articles?  Does it point you to the next article in the "for" loop?  What about the end points - how do disable the Prev link on the first article and the Next link on the last article?

Chris Farmer
Friday, December 7, 2001

next or previous would seem to be best implemented as null if you are at the start or end of a folder.

This may argue for next_in_folder or next_all depending on which one makes more sense.

As to next in a for loop vs. next in a folder, I'm pretty sure the two are the same thing now - are they not?

I often see suggestions and comments based on the folder issue. Many people (myself included) would like to iterate over articles on a per-folder basis. It would seem that a clean solution here would also have something to say about next and back.

Maury Markowitz
Friday, December 7, 2001

Ok, in the end case the variable could default to null, but if the variable is just the URL, how do you change the HTML accordingly?  I would expect that a lot of people wouldn't want to have any link at all if the article is the first or last in the series.

For example, how do you write
      <a href="{$.next$}">NEXT</a>
in such a way that it displays nothing at all when the $.next$ is null?

Chris Farmer
Friday, December 7, 2001

Aha, you're discovering why we decided that "next" and "previous" were too hard for the first release :)

To really make it work, you need if statements, "first" and "last" predicates, and a way to specify what you mean by "next". (It could be the order in the folder, it could be alphabetical order, it could be order sorted by date...) For example, what if you have two index pages -- one lists the most popular articles, the other lists all articles sorted by date. Each article has a NEXT button. What does NEXT do? It would have to remember which index you came in from! Ugh.

Don't worry, we'll find SOME way to solve this, eventually, but it was complicated enough that we had to punt for 1.0...

Joel Spolsky
Friday, December 7, 2001

I just finished with a site that has 38 "next chapter" links.  When I started, I was begging for automatic generation of "next" links.

I now realize that I'll rarely do a site like that again and because it's a book and the chapters will always appear in the same order, I will never have to regenerate the "next" links.  Given that each chapter was 1000 - 2000 words, adding a link to the bottom of each one wasn't too bad and I'll never need to change them (I think)

Thinking about it after learning a little about CityDesk, what I would prefer a related feature:

"If this link points to the page it's on, deactivate the link (unless it's a bookmark)"  Maybe we put a keyword at the top of the page (like the date formatting instructions) to specify {$deactivate_self_links$}

That would allow me to have an index to all of the chapters in each chapter.  It would help in navigating because the deacivated link would tell the surfer where he is, and he could go forward, backward or skip around if he wants. handles its multi-page articles uses type of navigation.

So I want to change my vote from "next"  and  previous" links to "deactivate self links"

Terry Kearns
Friday, December 7, 2001

All good points Joel. Well seeing as you've now promised this feature (heh, sucker) and it looks like most of my other concerns are being addressed in the future as well, I think it's time to buy.

Maury Markowitz
Saturday, December 8, 2001

*  Recent Topics

*  Fog Creek Home