Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Supressing retrieval of CURRENT Article (self)

Folks,

It has already been mentioned that it is not possible for a script to set a variable (see http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=3020&ixReplies=2 )

Therefore, this technique cannot be used to indicate the what page is being generated.

Is there any other way?  This has come up because I have a linear series of Articles that I want to display with the same template.  On the left-hand nav-bar I want to have buttons to the previous and next Articles.  I can retrieve the Articles in the correct order because of the way they are named.  But I want to suppress the creation of the button to the Article that is currently being dislayed. 

The loop that retrieves the Articles needs to be written so as to not retrieve the current Article. 

Furthermore, this code also does not seem to work:

{$ foreach x in (and (folder "About") (not (filename "{$.filename$}"))) SortAscendBy .filename $}

The idea here is that we will retrieve all Articles from the specified folder except the one that has a filename equal to the filename of the page currently being generated.  This fails because the "{$.filename$} " that is internal to the "{$ foreach $}" is not evaluated.  This can be proven by setting a variable, "k_foo", to the actual value of an Article's filename and replacing  "{$.filename$}" with "{$.k_foo$}".

Does anyone have a suggestion as to how to workaround this issue and suppress the individual link to the curent Article?

Thanks in advance for all suggestions.

Joel Finkel

Joel
Wednesday, March 05, 2003

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=850&ixReplies=6

I presume it could be done with javascript.

tk
Wednesday, March 05, 2003

I thought I'd knock together a quick template that gives you previous / next article functionality using a bit of php scripting. In the template you can add articles and they'll automatically have working links to the next and previous articles in the same folder. You can mess with the php code to change the behaviour quite easily and if nothing else it shows how to use cityscript and php together.

http://www.johnsadventures.com/backend/PrevNextTemplate/index.html

The usual problem with php is that you can't use Preview to preview the site, you have to publish it, by the way.

John Conners
Wednesday, March 05, 2003

Set up a localhost webserver with the same environment as your production server. Publish locally and preview without going public. Good way to check links, too.

Amos
Thursday, March 06, 2003

*  Recent Topics

*  Fog Creek Home