Count Variable for the Category Variable Pair
Posted: 03 October 2007 09:11 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  134
Joined  04-14-2004

I’d like to display the text “Catgories: “, followed by a comma separated list of all categories assigned to an individual entry.  If there are no categories, I don’t want to display “Catgories: “.

As discussed here with a php workaround to hold anyone over:
http://expressionengine.com/forums/viewthread/61424/

 Signature 

http://www.cameroncorda.com | http://www.bluestatedigital.com

Profile
 
 
Posted: 04 October 2007 08:05 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  01-20-2006

I posted the same thing this past week. Second. If it’s the standard operation for looping variable pairs, then even if {count} isn’t available, a {category_counter} or something would be nice.

 Signature 

AJ Penninga
Pretty Squares, LLC - http://www.prettysquares.com

Profile
 
 
Posted: 12 October 2007 10:57 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  03-23-2006

I just came across the thread now.

But shouldn’t it be possible to do the following:

{assign_variable:current_cat="{exp:weblog:entries weblog="yourweblog" limit="1" status="not home" disable="trackbacks|member_data|pagination"}{categories backspace='1'}{category_name}|{/categories}{/exp:weblog:entries}"}

{if
"{current_cat}"!=""}
Categories
: {current_cat}
{
/if}

I didn’t test the code and it may be that you run into trouble since assign_variable is on e of the first things parsed. But it most certainly does run (tested) if you call this as an embed:

{embed="embeds/yourembededcall"
    
current_cat="{exp:weblog:entries weblog="hazmat" limit="1" status="not home" disable="trackbacks|member_data|pagination"}{categories backspace='1'}{category_id}|{/categories}{/exp:weblog:entries}"

and in the embeded template

{if "{embed:current_cat}"!=""}
Categories
: {embed:current_cat}
{
/if}


}

Profile
 
 
Posted: 18 December 2007 05:54 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  37
Joined  02-10-2007

I too would like to request a count variable for category variable pair. It’s surprising that this isn’t included out of the box already. I can’t imagine too many situations where you’d want to display the current post’s categories without some kind of context to explain what you’re showing.

Profile
 
 
   
 
 
‹‹ Trackbacks off by default      Small typo ››
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: 65026 Total Logged-in Users: 43
Total Topics: 82115 Total Anonymous Users: 19
Total Replies: 441304 Total Guests: 195
Total Posts: 523419    
Members ( View Memberlist )
Newest Members:  meenoiYang.JianuoioitsukiNathan HammondalexcigadamstaneckiLucas Mayscybermilltstitt