Get Section Handle From Group I have a landing page on my site where I want to list a group of sections that have entries. I also need to access the section handle of that same group of sections.

I am having problems getting the section handle for the sections.

Currently I get an error back that says impossible to access attribute ("handle") on a string variable.

        {% set specialEntries = craft.entries.section(['sec1','sec2','sec3']) %}

        {% set grouped = specialEntries|group('section') %}
        {% for section, specialEntries in grouped %}
            &lt;h1&gt;{{ section }} - {{ section.handle }}&lt;/h1&gt;
        {% endfor %}
In your example, you're attempting to use a SectionModel instance as the key for your grouped entries. This is not possible.

What actually happens behind the scenes is the group filter generates an object where the keys are the string value of the SectionModel instance [1], and the values are the EntryModels associated with that section.

There are a few ways of achieving your desired outcome. Here's one possibility (not tested):

{% set sections = craft.sections.getAllSections() %}
{% set entries = craft.entries.section(['first', 'second', 'third']) %}
{% set grouped = entries|group('section') %}

{% for sectionHandle, sectionEntries in grouped %}
    {% set groupSection = false %}
    {% for section in sections %}
        {% if section.name == sectionHandle %}
            {% set groupSection = section %}
        {% endif %}
    {% endfor %}

    {% if groupSection %}
        &lt;h1&gt;{{ groupSection.name }} - {{ groupSection.handle }}&lt;/h1&gt;
    {% endif %}
{% endfor %}




[1]: The SectionModel::__toString method returns the name attribute.