Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Category Link in the Blog Entry

There is a good point about creating blog categories here http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=10057&ixReplies=1 , but how to attach link to respective category to an article?
For example, I create an blog entry, put into its 'keywords' field "[Life]" and make it visible inserting '{$.keywords$}' in 'blogentry' template. Becides I create folder 'archive/categories' and create article 'Life' in it. But how to make link in corresponding blog entry to this category article?

Naivi
Sunday, October 12, 2003

Create a foreach loop to loop on articles in that folder, or with that keyword?  Is that what you are trying to do?

Joel Goldstick
Sunday, October 12, 2003

It's like this:
1) I have Blog-Article with category 'Life'.
2) In the end of this Blog-Article there is "from category: Life".
3) I have folder 'Category', where I have Category-Article 'life.html' which contains list of Blog-Articles from this category.
4) Now I want to get link to this Category-Article in the end of Blog-Article from paragraph 1).

Of course I can use one of extra fields (e.g. extrafield2) and manually input path to corresponding Category-Article (in this case, "../../caregories/life.html"). But point is to get in automatically in some way...

Naivi
Sunday, October 12, 2003

The problem I was attempting to address wasn't exactly the same as yours.  But my problem and yours appear to be similar enough that you could use the approach I used.

What I did was created a separate template for each "section" of my website (in your case, a separate template for each "category"), and put the appropriate links into the template.

That way, City Desk's publication process would automatically "stamping out" the appropriate links on each article.

There are several drawbacks for your application, though:

1)  Of course, this will only work if your blog entires can only belong to a single category.  If an entry could belong to multiple categories, the above solution would not work.

2)  You would have to assign the appropriate template to the article at entry time.  This involves remembering to do this, involves a few extra steps with each article, etc.

Also, changing the category for just a couple articles would be fairly easy, but if you wanted to migrate a bunch of articles this would be very time consuming and problematic.

3)  You will experience the same problem I have not yet been able to work around -- template proliferation.  This makes management and maintenance a bit more difficult.

Until City Desk incorporates some kind of "file level" include (instead of article-level include), and/or adds some more advanced and file-level scripting capabilities, I don't see any way around my current quandary.


Still, this solution works for me, because I only have a few sections on my website.  If you only have a few categories, and the other above criteria are met, then my solution could work for you.

Just thought I'd offer.

Kevin
Sunday, October 12, 2003

I see another way. Two, really.

1) For every blog-article we can use extrafield1 for full name of corresponding category and extrafield2 - for magic name of category-article, so we can create link to category using this fields. Disadvantages: first, we are waste two valuable fields; and second, we can attach a blog-article to two different categories.
2) We can create loop consequently seeking all names from category field and then, according to it, create the corresponding link.  We also can save this loop as variable.
Disadvantages: it is absolutely manual method; besides we will need to change this loop every time we add new category.

Kron
Monday, October 13, 2003

CORRECTION:

1) For every blog-article we can use extrafield1 for full name of corresponding category and extrafield2 - for magic name of category-article, so we can create link to category using this fields. Disadvantages: first, we are wasting two valuable fields; and second, we CAN NOT attach a blog-article to two different categories.

Kron
Monday, October 13, 2003

Inspiration just struck.  There may be a much more elegant solution to this problem. 

I haven't played with the City Desk scripting very much, so someone please correct me if the following wouldn't work.

What about editing your template, and inserting code like this:

{$ if keywordContains("[Life]")  $}
<a href="***insert magic number for index***">Life Index</a>
{$ endif $}

Copy and repeat the above block for each category, inserting the correct magic number.

If the "keywordContains" function works on thisArticle, then you could have your articles belong to multiple categories -- and they will show up in the appropriate category indices!

If "keywordContains" doesn't work, then at worst you could use a field other than keywords, like "Extra 1".  Then the IF statement block above should work, but you'd again be restricted to a single category per article (unless someone knows of another "find" type of function that can be run on other fields).

Kevin
Tuesday, October 14, 2003

Nuts.  Naturally, it's not that simple.  The only thing a {$ if $} expects is "blank" or "nonblank".  You can't do keywordContains or comparison between a string value and a field.  :(

Kevin
Tuesday, October 14, 2003

*  Recent Topics

*  Fog Creek Home