[link to discussion] I'll assume for the example that you have all your questions in a folder called "Questions" and each question is its own article. The headline of the article is the question (e.g. How do I cook spotted trout?) and the body is the answer (e.g. I cookthem like so...). Put a UNIQUE identifier in each extra1 field for the articles (e.g. Trout) which will be used to make the bookmark.
Then in either an article or an html file, add these foreach loops (in the HTML view):
1. at the top to generate the list of questions...
{$foreach x in (folder "Questions")$} <a href="#{$x.extra1$}">{$x.headline$}</a><br> {$next$}
2. at the bottom to generate the list of answers...
{$foreach x in (folder "Questions")$} <a name="{$x.extra1$}">{$x.headline$}</a><br> <blockquote>{$x.body$}</blockquote> {$next$}
That's all. Notice that the href for a bookmark has a # in front of it, and the part you want it to go to is surrounder by an <a name="bookmark"> tag.
You can use it in an article inside the folder.. Just put the keyword INDEX in the keywords field and modify the foreach loop to be
(and (folder "Questions") (not (keyword_contains "INDEX")))
Michael H. Pryor Friday, January 04, 2002
I made a couple additions to the script that others may find handy.
1. In HTML view I put <a name="top"></a> as the first line so I could "Return to Top"
2. I added <p> </p> between the scripts to give a little extra spacing between the list of questions and answers.
3. I made the .Headline bold so it stands out.
4. Added <p><a href="#top"><i>Back to Top</i></a></p> after the blockquote so you don't have to scroll back up. A personal issue on my part.
Here's my version of the script:
{$foreach x in (and (folder "Conditions") (not(keyword_contains "Index")))$} <a href="#{$x.extra1$}">{$x.headline$}</a><br> {$next$} <p> </p> {$foreach x in (and (folder "Conditions") (not(keyword_contains "Index")))$} <a name="{$x.extra1$}"><b>{$x.headline$}</b></a><br> <blockquote>{$x.body$}</blockquote> <p><a href="#top"><i>Back to Top</i></a></p> {$next$}
An observation on sticking scripts and text on the same page: I've found that if you create an article in Normal View and then insert the script in HTML view you're fine. However, once I switch back from HTML to Normal, my script gets mangled.
Eric Chromick Sunday, January 13, 2002
[link to discussion] Because all the article bodies appear on the topic pages, you don't really want to publish each question/answer as its own html page. You can't currently tell CityDesk not to do that.
To work around this, I just created an empty template called "Blank" and assigned it to each question/answer article. So an empty html file gets published for each of those articles, but it's quick to upload (because it's zero length). Nothing on my site links to the individual articles, so readers never see them. They do exist, and it annoys me slightly because it's a little untidy, but it works.
I should add this to the FAQ :-).
Darren Collins Wednesday, February 05, 2003
|