Answers.Body: <p>There is a great tutorial over at <a href="http://straightupcraft.com/articles/how-do-i-only-display-a-list-of-categories-that-have-entries-and-hide-empty-categories">Straight Up Craft</a> for handling this (it is however very similar to what you have - it may speed things up a tad though).</p>
  
  <blockquote>
    <p>First, we want to grab all of the entry ids from the Section of
    content which we want to display categories for.</p>
    
    <p><code>{% set entryIds = craft.entries.section('blog').ids() %}</code></p>
    
    <p>Next, we will use the craft.categories tags relatedTo() method to only
    return categories that have a relationship with one of our entry ids.</p>
    
    <p><code>{% set categories = craft.categories.relatedTo({ sourceElement:
    entryIds }).groupId(1).find() %}</code></p>
    
    <p>Once we have our list of categories that are in use, we can loop
    through those categories and display them in our template:</p>
  
  <pre><code>{% for category in categories %}
      &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-23T16:33:02.010Z
Answers.LastActivityDate: 2014-07-23T17:40:35.433Z
Answers.LastEditDate: 2014-07-23T17:40:35.433Z
Answers.UserDisplayName: Ryan Shrum
Body: <p>I want to list all categories that have an entry assigned to them, but hide the ones that are empty.</p>
  
  <p>In EE I could do this <code>show_empty="no"</code></p>
  
  <p>But I can't see a parameter in the docs for Craft.</p>
  
  <p>Currently I've found that I could use relatedTo but with passing an object with up to 600 entries it dies with caching tags :(</p>
  
  <p>Is there a better way of doing this? This is what I've got at the moment:</p>
  
  <pre><code>{% set blogPosts = craft.entries({section:'blog',limit:null}).find() %}
  
  {% for cat in craft.categories({groupId:2}).relatedTo(blogPosts) %}
     &lt;li&gt;&lt;a href="/blog/{{cat.slug}}"&gt;{{cat.title}}&lt;/a&gt; &lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Tags: <entries><templating><categories>
Title: Check to see if category is populated?
ThreadText: # Check to see if category is populated?
  
  (Asked by: username_0 on 2014-07-23)
  
  I want to list all categories that have an entry assigned to them, but hide the ones that are empty.
  
  In EE I could do this `show_empty="no"`
  
  But I can't see a parameter in the docs for Craft.
  
  Currently I've found that I could use relatedTo but with passing an object with up to 600 entries it dies with caching tags :(
  
  Is there a better way of doing this? This is what I've got at the moment:
  
  ```
  {% set blogPosts = craft.entries({section:'blog',limit:null}).find() %}
  
  {% for cat in craft.categories({groupId:2}).relatedTo(blogPosts) %}
     <li><a href="/blog/{{cat.slug}}">{{cat.title}}</a> </li>
  {% endfor %}
  
  ```
  
  **Tags:** entries, templating, categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-23. Score: 14 | Accepted answer
  
  There is a great tutorial over at [Straight Up Craft](http://straightupcraft.com/articles/how-do-i-only-display-a-list-of-categories-that-have-entries-and-hide-empty-categories) for handling this (it is however very similar to what you have - it may speed things up a tad though).
  
  > First, we want to grab all of the entry ids from the Section of
  > content which we want to display categories for.
  >
  > `{% set entryIds = craft.entries.section('blog').ids() %}`
  >
  > Next, we will use the craft.categories tags relatedTo() method to only
  > return categories that have a relationship with one of our entry ids.
  >
  > `{% set categories = craft.categories.relatedTo({ sourceElement:
  > entryIds }).groupId(1).find() %}`
  >
  > Once we have our list of categories that are in use, we can loop
  > through those categories and display them in our template:
  >
  > ```
  > {% for category in categories %}
  >     <li><a href="{{ category.url }}">{{ category.title }}</a></li>
  > {% endfor %}
  >
  > ```
  
  
  ---
  
  