1 of 2
1
Category show_empty=“no” behaviour to act according to weblog context
Posted: 15 July 2007 12:34 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  171
Joined  06-18-2007

I assumed the following code:

{exp:weblog:categories weblog="publications" show_empty="no" }
{category_name}
{
/exp:weblog:categories}

would only reveal the categories that have entries in “publications”.

But instead, it reveals categories that have been used in all weblogs, defeating the purpose of having a category list for “publications”.

It seems incongruent with the way expression engine works in other cases, where restricting by weblog does work.

Profile
 
 
Posted: 16 July 2007 05:50 AM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

Hi Richard, what build/version are you running?

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 16 July 2007 06:12 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  171
Joined  06-18-2007

ExpressionEngine 1.6.0 Build:  20070626

Profile
 
 
Posted: 16 July 2007 07:04 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

Try upgrading to the latest build, there were some bugs with categories on that build. After upgrading, you may need to go into edit each category and just hit update.

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 16 July 2007 07:47 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1097
Joined  03-22-2006

My bad, I’ve misinterpreted your post.

Yes this does seem out of place… +1 on the FR smile

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 10 January 2008 01:56 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  90
Joined  11-25-2002

I expected it to work that way too? Strange that it does not.
Did you come up with another solution?
I really need this feature.

Profile
 
 
Posted: 13 January 2008 11:03 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  171
Joined  06-18-2007

No I didn’t. I’m currently manually hiding categories that aren’t relevant…

I hold out hope that this will be solved soon.

Profile
 
 
Posted: 24 January 2008 03:44 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  208
Joined  07-23-2005

Same situation:

{exp:weblog:categories weblog=“products” show_empty=“no”}
{category_name}
{/exp:weblog:categories}

There are NO entries in the “products” weblog that are assigned to “Category X”, but “Category X” still appears in the list. Why? Because there is an entry in the “news” weblog that is assigned to “Category X”.

Another post suggested that this is “exptected behavior”. I have to disagree and put my voice behind this request. This is a bigger deal than one might expect.

Thanks,
Philip

 Signature 
Profile
 
 
Posted: 27 February 2008 09:05 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  28
Joined  12-30-2006

richard, or anyone else-

can you explain how you are manually hiding categories that aren’t relevant??

i’d like to do the same thing and have no idea what i’m doing!

thanks!

Profile
 
 
Posted: 28 February 2008 12:48 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  171
Joined  06-18-2007

Hi


It’s a parameter in the weblog categories tag: http://expressionengine.com/docs/modules/weblog/categories.html#par_show

Profile
 
 
Posted: 29 May 2008 08:34 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  35
Joined  11-27-2007

I, too, found this very frustrating to discover! Not to mention the time it took trying to figure out what was going on.

The show_empty=“no” parameter is not working when a category group is used in more than one weblog, in which case all category names are shown, whether empty or not.

At any rate and after much experimentation, here’s a workaround that’s working for me. Maybe not efficient, but it does result in only used categories being listed.

{exp:weblog:categories weblog="products" style="linear" show_empty="no"}
    {exp
:weblog:entries weblog="products" category="{category_id}" limit="1"}
        {category_name}
and whatever else... <br />
    
{/exp:weblog:entries}
{
/exp:weblog:categories}

Addendum 6/2/08

So, to take the above example one step further, a list of entries with category headings might look like this…

{exp:weblog:categories weblog="products" style="linear" show_empty="no"}
    {exp
:weblog:entries weblog="products" category="{category_id}" limit="1"}
        {category_name}
and whatever else... <br />
    
{/exp:weblog:entries}
    {exp
:weblog:entries weblog="products" category="{category_id}"}
        {title}
        {description}
        {et_cetera}
    {
/exp:weblog:entries}
{
/exp:weblog:categories}

Profile
 
 
Posted: 30 May 2008 01:47 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
RankRank
Total Posts:  171
Joined  06-18-2007

Thanks, looks promising, will try it out on my next project.

Profile
 
 
Posted: 05 June 2008 10:03 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  881
Joined  02-15-2008

I just had this very same issue.

Will workaround it for now, but I really don’t understand why on earth it would work the way it does currently so I would love to see this “fixed”.

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!
Remember - If at first you don’t succeed, you’re not Chuck Norris

Profile
 
 
Posted: 12 August 2008 06:13 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  323
Joined  03-18-2007

I’d like to add my vote for this feature as well. I got stung by it here:

http://expressionengine.com/forums/viewthread/88038/

I’m trying to make a list of used categories/tags on the side of the blog, but the list doesn’t make sense when categories clearly unrelated to that weblog, but related to a different portion of the site, are listed.

How are people getting around this without doing an extra exp:weblog:entries request for every category they have?

Thanks,
Matt

Profile
 
 
Posted: 17 August 2008 12:41 PM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  323
Joined  03-18-2007

I solved this using the query tag:

{exp:query sql="select distinct t1.cat_url_title, t1.cat_name from exp_categories t1, exp_category_posts t2, exp_weblog_titles t3 where t1.cat_id = t2.cat_id and t2.entry_id = t3.entry_id and t3.weblog_id = '3'"}
<a href="{path=template_group}tags/{cat_url_title}">{cat_name}</a><br />
{/exp:query}

Make sure you change weblog_id to be the one you actually want. Also, that doesn’t take dates into account at all—if you only want to show tags for posts that haven’t happened yet, it needs to be:

{exp:query sql="select distinct t1.cat_url_title, t1.cat_name from exp_categories t1, exp_category_posts t2, exp_weblog_titles t3 where t1.cat_id = t2.cat_id and t2.entry_id = t3.entry_id and t3.weblog_id = '3' and convert_tz(from_unixtime(entry_date), '+00:00', '-5:00') < now()"}
<a href="{path=template_group}tags/{cat_url_title}">{cat_name}</a><br />
{/exp:query}

I make sure it’s exact by converting the entry_date timestamp (which is stored in GMT) to my time zone (in this case, -5 hours). If you use that make sure to put your own time zone time. If you don’t care about time zones, only the date, it can just be “and from_unixtime(entry_date) < now()”.

Hopefully that helps somebody.
-Matt

Profile
 
 
Posted: 19 September 2008 04:56 AM   [ Ignore ]   [ # 15 ]  
Lab Assistant
RankRank
Total Posts:  122
Joined  07-21-2006

I would like to support this request as well. I have a project where to weblogs share the same category group and in the news weblog there should only be categories available, that actually have entries.

I would also like to thank you, Slapshotw, for coming up with the code. Works great for me grin

Wolfram

Profile
 
 
Posted: 19 September 2008 04:35 PM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  323
Joined  03-18-2007

Glad it helped Wolfram!

Profile
 
 
Posted: 22 September 2008 07:38 AM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  156
Joined  07-08-2008

Guess I’m another user who found this function a problem.

slapshotw, I’m trying to use your solution but I need to put in parent_only=“yes”.  Do you know how I can do that with the SQL statement?

Thanks

Profile
 
 
Posted: 22 September 2008 08:28 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  156
Joined  07-08-2008

Alright, I made a version for parent_only=“yes”.  Was pretty simple once I looked into the DB.

This version also takes in a weblog name instead of having to put an ID.  The ID is automatically found for the weblog.

{exp:weblog:entries limit="1" weblog="{my_weblog}"}
    {exp
:query sql="
        SELECT DISTINCT t1.cat_url_title, t1.cat_name
        FROM exp_categories t1, exp_category_posts t2, exp_weblog_titles t3
        WHERE t1.cat_id = t2.cat_id
            AND t2.entry_id = t3.entry_id
            AND t3.weblog_id = '{weblog_id}'
            AND t1.parent_id = 0
    "
}

        
<a href="{path=template_group}tags/{cat_url_title}">{cat_name}</a><br />
    
    
{/exp:query}
{
/exp:weblog:entries}

Profile
 
 
   
1 of 2
1
 
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: 64900 Total Logged-in Users: 58
Total Topics: 81835 Total Anonymous Users: 48
Total Replies: 439972 Total Guests: 305
Total Posts: 521807    
Members ( View Memberlist )