EllisLab text mark
Advanced Search
     
Quick question on show-empty category parameter
Posted: 07 May 2012 05:18 PM   [ Ignore ]
Joined: 2011-07-15
31 posts

Hello,

I have a category based navigation on a product page that has the following code to it:

{exp:channel:categories channel="Categories" parent_only="yes"}
            
<div class="link_list">
                <
a href="{path='categories'}">{category_name}</a>
            </
div>
{/exp:channel:categories} 

I wanted to make this so that it only showed the categories that actually have visible items in it, so I found the show_empty= parameter.  I tried this and when I added it to the code and set it to no, it hid everything.

Unfortunately all but two of seven categories have entries in them.

I then tried adding other tags like show_future_entries=“yes” and that made everything show up, even if there were no entries in them.

The problem I think I have is that all of the categories have entries, but depending on the status of the member, some of them don’t show any.

So even when I try and do a conditional statement, it doesn’t seem to work.  Below is what I have:

{if logged_in AND (member_group == "1" OR member_group == "6")
         {exp
:channel:categories channel="Categories" parent_only="yes"}
                
<div class="link_list">
                    <
a href="{path='categories'}">{category_name}</a>
                </
div>
       
{/exp:channel:categories}
        {if
:else} 
          {exp
:channel:categories channel="Categories" parent_only="yes"  show_empty="no"}
                
<div class="link_list">
                    <
a href="{path='categories'}">{category_name}</a>
                </
div>
          
{/exp:channel:categories}
        {
/if} 

Thanks for any help you can provide!

 
Posted: 08 May 2012 05:34 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi feeneywireless,

You might have better luck if you break your conditional down a bit further:

{if logged_in}
 {if member_group 
== "1" OR member_group == "6"
   {exp
:channel:categories channel="Categories" parent_only="yes"}
    
<div class="link_list">
     <
a href="{path='categories'}">{category_name}</a>
    </
div>
   
{/exp:channel:categories}
 {if
:else} 
   {exp
:channel:categories channel="Categories" parent_only="yes"  show_empty="no"}
    
<div class="link_list">
     <
a href="{path='categories'}">{category_name}</a>
   </
div>
  
{/exp:channel:categories}
 {
/if}
{
/if} 

Breaking the conditional down helps speed things up for one, but in this case it may get you around ExpressionEngine’s Parse Order.

Cheers,

 Signature 

How may I help you?

 
Posted: 08 May 2012 07:48 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-07-15
31 posts

Thanks for the feedback Dan!  I actually still get no results. If I login as 1 or 6 I get all the results because they all have products, but when I logout or login with a different member status, I get no results.

Also, below is my new code. I realized that the people logged out would see nothing, so I had to add a conditional to the end of the if logged in section. Which might be defeating the purpose of the method you prescribed.

{if logged_in}
         {if member_group 
== "1" OR member_group == "6"
           {exp
:channel:categories channel="Categories" parent_only="yes"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
            </
div>
           
{/exp:channel:categories}
         {if
:else} 
           {exp
:channel:categories channel="Categories" parent_only="yes" show_empty="no"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
           </
div>
          
{/exp:channel:categories}
         {
/if} 
        {if
:else} 
           {exp
:channel:categories channel="Categories" parent_only="yes" restrict_channel="no" show_empty="no"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
           </
div>
          
{/exp:channel:categories}
        {
/if} 
 
Posted: 14 May 2012 04:24 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi feeneywireless,

Ok, let’s step back a bit here.

Can you give me each condition and the content you want displayed under those conditions?

So, if 1 or 6 are logged in, I want this information.

If any other groups, this information.

If no one is logged in, this information.

Take it outside of ExpressionEngine and tell what you want to see in each of those conditions.

Cheers,

 Signature 

How may I help you?

 
Posted: 14 May 2012 04:48 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2011-07-15
31 posts

Thanks so much for the response!  Here is the function of the site:

To provide a set of product descriptions for members of Group A and a more complete listing of products for members of Group B.

Which I have now by using conditionals and status ranges.

The problem is that some of the categories appear empty to Group A, but actually have products assigned to them that can be viewed by Group B.  Technically, Group B will be able to see all products all the time, so that is an easier solution for the empty categories.

The problem is, I want to hide the categories that appear to have no products from Group A.

I hope this makes sense. 

Group B gets seven categories, Group A only gets five, for example.

Thanks again!

 
Posted: 17 May 2012 05:51 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi feeneywireless,

Thanks for the explanations!

I think the better approach here is through Category Groups rather than Member Groups. Actually, a combo of the 2.

Since entries can have more that one category assigned, it would be easier to manipulate the display by category.

Consider this:
You have Member Group A and Category Group A

Member Group B and Category Group B

So it would be, if member group a, then category a, if member group b, category a and b.

Does that make sense?

Cheers,

 Signature 

How may I help you?

 
Posted: 21 May 2012 01:10 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2011-07-15
31 posts

Thanks so much for your feedback!  I am not sure I 100% understand the solution, but I did find that you can use the status parameter for limiting categories in a navigation link list.

I tried to implement that, since the status drop down is the method we are using to delineate what products can be viewed by what people. 

I tried to use it, but found that it is not limiting the results.  I wonder if there is something wrong with my syntax.  Below is the code for this:

{if logged_in}
         {if member_group 
== "1" OR member_group == "6"
           {exp
:channel:categories channel="Categories" parent_only="yes"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
            </
div>
           
{/exp:channel:categories}
         {if
:else} 
           {exp
:channel:categories channel="Categories" parent_only="yes" status="not Covert"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
           </
div>
          
{/exp:channel:categories}
         {
/if} 
        {if
:else} 
           {exp
:channel:categories channel="Categories" parent_only="yes" status="not Covert"}
            
<div class="link_list">
             <
a href="{path='categories'}">{category_name}</a>
           </
div>
          
{/exp:channel:categories}
        {
/if} 

 
Posted: 24 May 2012 04:25 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi feeneywireless,

Have you made sure to use the status name exactly? And you are sure the status group has been assigned to the channel?

As an aside, you can still simplify the conditional like so:

{if logged_in_member_group == OR logged_in_member_group == 6}
   {exp
:channel:categories channel="Categories" parent_only="yes"}
    
<div class="link_list">
     <
a href="{path='categories'}">{category_name}</a>
    </
div>
   
{/exp:channel:categories}
{
/if}
{if logged_out} 
  {exp
:channel:categories channel="Categories" parent_only="yes" status="not Covert"}
   
<div class="link_list">
    <
a href="{path='categories'}">{category_name}</a>
   </
div>
  
{/exp:channel:categories}
{
/if} 

The fewer ifs and elses, the better and easier to maintain.

Cheers,

 Signature 

How may I help you?