Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Spaces in headlines used in Target Links

I have a script to generate target links that I got from another post in the forum. The problem is that several of my headings contain spaces and the links that contain spaces don't work. Anyone know what to do here? I'm really in a bind.

Thursday, March 13, 2003

could you post the script so we could look at it?
Thursday, March 13, 2003

{$ foreach x in (folder "foldername/foldername")SortAscendBy .extra1  $}

<li><a href="#{$x.headline$}">{$x.headline$}</a><br>
{$ next $}

Then, I put <a name="{$.headline$}">{$.headline$}</a> Tags around each headline.

Thursday, March 13, 2003

This is one of mine that works fine.  It's the thing you are missing.  This one creates a bulleted list of links our most recent meeting minutes. (It that's the sort of thing you are trying to do.)

<UL>{$ foreach 5x in (and(folder "Minutes")(not(keyword_contains "archive")))$}
<LI><A href="{$$}">{$x.headline$}<BR></A>{$next$} </LI></UL>

Thursday, March 13, 2003

First, you do realize your script will only work if everything is on the same page. I'm sure you do, but it doesn't hurt to check.

What's the Extra 1 field? Is it nice and short with no funny characters?


<a href="#{$x.extra1$}">{$x.headline$}</a>


<a name="{$.extra1$}">{$.headline$}</a>
Thursday, March 13, 2003

Yes, I realize that it will only work if they are all on one page. They are. It is an FAQ and the non-CD version is at . Essentially, each section of questions is it's own article and there is code to call out the articles onto the page with the target links. I don't want to use the extra1 field because I am supposed to be making these things "easy for the user" and having to remember to put something in the extra1 field is not easy.

Thursday, March 13, 2003

I think the problem here is that an a reference can't have spaces.  So, one way to solve this is to make sure you name your articles without any space.  Like this maybe:


you can then use the filename variable as the name of the reference, but use the headline for the link text

joel Goldstick
Thursday, March 13, 2003

Yes, the problem is that references can't contain spaces. For this reason, I use the Extra1 field to create the reference text in the CityDesk FAQ (have a look at to see what I mean).

For example, my article with the Headline "Reviews Of CityDesk" has "reviews" in the Extra1 field, and this is what's used to create the links and name tags.

Darren Collins
Thursday, March 13, 2003

Oh... You sorted them by extra1, so I thought something was in extra1.

Since the loop gets everything in a folder, how about making the "one page" an index article _in that folder_ with the keyword "index". Then making the loop condition:

(folder "blah")
(not (keyword_contains "index") )

Then you can use {$$} and the link won't have any slashes or spaces in it, it will just be "ArticleName.html".
Thursday, March 13, 2003

I think the idea is to have a list of, say, 10 headings at the top of the page (one for each article), and then have each of those headings linked to a placeholder lower down in the page where the actual article contents are printed.

So you've got one loop at the top of the page to generate the headings linked to bookmarks, and a second loop just under that to include the actual article bodies and tag them with bookmarks.

Darren Collins
Thursday, March 13, 2003

I had used the same code on another page and it works: (this is from view-->source - I wanted to verify that it was using the headline as the a name="".)

<P class=bullet><A href="#Recent Press Releases">Recent Press Releases</A></P>
<P class=bullet><A href="#Upcoming Events">Upcoming Events</A></P>
<P class=bullet><A href="#Media Center">Media Center</A></P></LI></UL><BR><BR>
<H2>Recent Press Releases</H2><A name="Recent Press Releases">

So now I have to figure out what it is about the other page that causes it not to work.

Friday, March 14, 2003

*  Recent Topics

*  Fog Creek Home