<p>To achieve an empty state for my group (When there's no entries existing within that group). I re-assembled the array and outputted them in a certain order - allowing for an <code>if</code> to come alive when there actually wasn't any status available.</p>

<pre><code>{% set proposals = craft.entries.section('proposals').authorId(currentUser.id) %}
{% set proposalsByGroup = proposals|group('proposalStatus') %}

{% for status in ['pending','accepted','delivered'] %}

  {% if proposalsByGroup[status] is defined %}
    {% set entriesInStatus = proposalsByGroup[status] %}
          {{ status }}
          {% for proposal in entriesInStatus %}
             Hello.
          {% endfor %}
  {% else %}
          {{ status }}
          Nothing here, but still gives a status that you've set above.
  {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2019-05-15T16:35:27.217Z
2019-05-15T16:35:27.217Z
JMKelley
<p>I have entries that are getting grouped, but I've noticed that it will return nothing if there's nothing within a group. I'm looking to see if there's a possibility of showing an empty state to a user? </p>

<pre><code>{% set loopCount = 0 %}
{% for status, proposals in proposalsByGroup %}
  {% if proposals|length %}
  {% set loopCount = loopCount + 1 %}
  &lt;div class="tab-pane fade" id="pills-{{ loopCount }}" role="tabpanel" aria-labelledby="pills-{{ status }}-tab"&gt;
    {{ status }}
      {% for proposal in proposals %}
          &lt;div class="row my-3"&gt;
            &lt;div class="col"&gt;
              &lt;div class="card"&gt;
                {% include 'proposal/_proposalInfluencer.html' %}
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
      {% endfor %}
  &lt;/div&gt;
  {% else %}
    There's nothing here!
  {% endif %}
{% endfor %}
</code></pre>

<p>Unfortunately, the above does nothing as no group actually exists so it won't run the code?</p>

<templating>
Entry Group Empty State
# Entry Group Empty State

(Asked by: username_0 on 2019-05-15)

I have entries that are getting grouped, but I've noticed that it will return nothing if there's nothing within a group. I'm looking to see if there's a possibility of showing an empty state to a user? 
{% set loopCount = 0 %}
{% for status, proposals in proposalsByGroup %}
  {% if proposals|length %}
  {% set loopCount = loopCount + 1 %}
  
    {{ status }}
      {% for proposal in proposals %}
          
            
              
                {% include 'proposal/_proposalInfluencer.html' %}
              
            
          
      {% endfor %}
  
  {% else %}
    There's nothing here!
  {% endif %}
{% endfor %}

Unfortunately, the above does nothing as no group actually exists so it won't run the code?

**Tags:** templating


---

## 1 answers

### Answer by username_0 on 2019-05-15. Score: 1 | Accepted answer

To achieve an empty state for my group (When there's no entries existing within that group). I re-assembled the array and outputted them in a certain order - allowing for an if to come alive when there actually wasn't any status available.
{% set proposals = craft.entries.section('proposals').authorId(currentUser.id) %}
{% set proposalsByGroup = proposals|group('proposalStatus') %}

{% for status in ['pending','accepted','delivered'] %}

  {% if proposalsByGroup[status] is defined %}
    {% set entriesInStatus = proposalsByGroup[status] %}
          {{ status }}
          {% for proposal in entriesInStatus %}
             Hello.
          {% endfor %}
  {% else %}
          {{ status }}
          Nothing here, but still gives a status that you've set above.
  {% endif %}
{% endfor %}


---

