Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Displayin Associated Images for Articles?

I want to generate an index of book reviews on my page. Rather than just linking with the headline tag I'd like to display the book cover AND the headline (the title for example).

Is this possible and how would I do  this.


Patrick Ansari
Wednesday, August 21, 2002

I suppose I could use extra1 and extra2 for this and manually paste HTML code in the text boxes provided but I find this a little bit messy to be honest. What happens when I delete the images and the HTML code in extra1 still points to them. This can become really messy as the site grows.

Patrick Ansari
Wednesday, August 21, 2002

ok this approach doesnt work either because the HTML source is converted to HTML &xxx; values. (< etc)

Patrick Ansari
Wednesday, August 21, 2002

You can put the image in an extra field or in the teaser with the teaser text.

In this page some of the teasers include images (I linked the image to the article).

In this page the image is in the sidebar

Here is the CityScript: The article title is "Extra2," the teaser is in "Extra1," and the picture is in "Sidebar."  It goes into a 2-column table.

<table border="0" width="90%">
<td>{$ foreach x in (or(folder "Mainpages")(folder "Workfolder"))&nbsp;$}
<td valign="top" align="left"><b><A href="{$$}">{$x.Extra2$}</A></b>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<td width="150" valign="center" align="left">{$x.Sidebar$}</td>

Wednesday, August 21, 2002

Ah nice one thanks. I guess I'm still thinking in more complex terms as is required for City Desk's simplicity. It's almost too simple for my taste ;p

Patrick Ansari
Wednesday, August 21, 2002

I've got two solutions that might help you.

For my book reviews and recommendations, I use a "content fragment" that I can include using a variable. The technique is explained here (and you can see one of the lists of books on the right hand side of the page):

This technique involves maintaining a separate article that contains all the book images and links, so you need to update that article whenever you add or remove a review. But, it's included everywhere via a variable, so once you update the article it gets updated everywhere.

The other technique is to put the book image in the Extra1 field of your review article, as you hinted at. I do something similar for my photography page:

Each thumbnail image is picked up from the Extra1 field of the corresponding photo's article, and the list is built using CityScript. It's a minor hassle adding all the thumbnails to the Extra1 fields (you can use the "Add Image" toolbar button to do it), but you don't have to update your index page when you add or remove articles. Alternatively, you could just copy and paste the corresponding thumbnail's Magic Name into the Extra1 field, and then have your CityScript loop add the necessary HTML around it to turn it into a link.

Hope this helps!

Darren Collins
Wednesday, August 21, 2002

Yep, thanks. I have added the picture to the extra1 field for now and I enclosed it with a link with {$$}.

Seems fair enough for the time being.

Patrick Ansari
Wednesday, August 21, 2002

I have a different workaround. See (dutch only)

each book = article
body = picture + optional link to ...
keywords= keywords....  (you can use this in combination with keyword_contains)

each book is assigned my 'empty' template (and is therefore published as an empty file).  I find the body a better place for storing images. Separating all fields makes it more flexible for scripts.

Adriaan van den Brand
Friday, August 23, 2002

*  Recent Topics

*  Fog Creek Home