Tip: Creating “Filed in: catergoy one, category two”
Posted: 15 October 2004 08:21 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  519
Joined  04-24-2004

This morning I was trying to figure out a way of listing my categories for a particular entry in this format: “Filed in: catergoy one, category two” where there may be none, one, or multiple categories, and “Filed in:” didn’t appear if there were no categories. The difficulty was I couldn’t test whether categories == “” or not, so I only had a choice of either:

A.

Filed in: category one
Filed in: category two
Filed in: category three

(ie “Filed in” appears for every loop (bad) but doesn’t appear when there are no categories (good))


or B.

Filed in: {categories}{/categories} where “Filed in:” appeared even if there were no categories (bad).

However using my css workaround for hiding paginate pages = 1 (4th post) I eventually realised I could so something similar, so now I have:

[b]<span class="category_text{categories}{category_id}{/categories}"><br />Filed in:</span>[/b]
{categories backspace
="1"}
<a href="{path=SITE_INDEX}">{category_name}</a>,
{/categories}

then in my css:

.category_text {display:none;}

The trick is in the span around “Filed in:” which will now be hidden whenever there are categories, because by adding category id’s to the class name it becomes something meaningless like “category_text3129” and is therefore ignored by the rule to hide it.

Err I hope that makes sense, thought it might come in handy for someone. Its pretty easy (despite my explanation smile

 Signature 

lukestevensdesign.com · Design 2.0 · Pro Network member

Profile
 
 
Posted: 21 October 2004 07:54 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  93
Joined  08-26-2003

Makes sense to me… very clever.  Hopefully won’t always be necessary to kludge, but it’s a good kludge.

Profile
 
 
Posted: 21 October 2004 08:47 PM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23528
Joined  05-20-2002

That’s sneaky smart!  Good one.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64939 Total Logged-in Users: 58
Total Topics: 81912 Total Anonymous Users: 40
Total Replies: 440330 Total Guests: 277
Total Posts: 522242    
Members ( View Memberlist )