<p>This kind of solved my problem:</p>

<pre><code>{% for section in craft.app.sections.allSections %}
    {% if section.type == 'channel' %}
        {% set navBarLinks = navBarLinks|merge([section]) %}
    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2019-08-26T13:53:09.343Z
if it solved your problem, you can accept your post as an answer.
inrsaurabh
CC BY-SA 4.0
2019-08-26T13:55:15.233Z
I can do that in 2 days apparently. Thanks!
ves
CC BY-SA 4.0
2019-08-26T13:44:35.840Z
2019-08-26T13:54:15.103Z
2019-08-26T13:54:15.103Z
ves
<p>I am trying to retrieve all Channel sections' names/titles.
This snippet contains the troublesome part. </p>

<pre><code>{% set allSections = craft.entries.all() %}
    {% for section in allSections %}
        {% if section.getType() == "channel" %}
            {% set navBarLinks = navBarLinks|merge([section.title]) %}
        {% endif %}
    {% endfor %}
</code></pre>

<p>allSections contains all entries (I know I am looking for sections but I don't know how to loop all sections. craft.sections returns null, since it's deprecated from Craft 2). ex:</p>

<p>I can see the entry inside a channel 'webshop/overview'. But I want to get only the name of the channel ('webshop' in this case).
Also I have 2 other channels without any entries inside them.</p>

<p>navBarLinks currently returns null. I want it to contain the names/titles of the Channel sections regardless if they contain entries inside them.</p>

<p>P.S. I am doing all this so I can have a dynamic navigation bar(similar to breadcrumbs but not exactly). I know Structure will make my life a lot easier but it doesn't quite fit my needs.</p>

<templating><craft3><craft-features><craft-pro><twigextension>
Craft 3 CMS How to get all Channel Names/Titles
# Craft 3 CMS How to get all Channel Names/Titles

(Asked by: username_0 on 2019-08-26)

I am trying to retrieve all Channel sections' names/titles.
This snippet contains the troublesome part. 
{% set allSections = craft.entries.all() %}
    {% for section in allSections %}
        {% if section.getType() == "channel" %}
            {% set navBarLinks = navBarLinks|merge([section.title]) %}
        {% endif %}
    {% endfor %}

allSections contains all entries (I know I am looking for sections but I don't know how to loop all sections. craft.sections returns null, since it's deprecated from Craft 2). ex:
I can see the entry inside a channel 'webshop/overview'. But I want to get only the name of the channel ('webshop' in this case).
Also I have 2 other channels without any entries inside them.
navBarLinks currently returns null. I want it to contain the names/titles of the Channel sections regardless if they contain entries inside them.
P.S. I am doing all this so I can have a dynamic navigation bar(similar to breadcrumbs but not exactly). I know Structure will make my life a lot easier but it doesn't quite fit my needs.

**Tags:** templating, craft3, craft-features, craft-pro, twigextension

---

## 1 answers

### Answer by username_0 on 2019-08-26. Score: 2 | Accepted answer

This kind of solved my problem:
{% for section in craft.app.sections.allSections %}
    {% if section.type == 'channel' %}
        {% set navBarLinks = navBarLinks|merge([section]) %}
    {% endif %}
{% endfor %}

> **Comments:**
> **username_1**: if it solved your problem, you can accept your post as an answer.  
> **username_0**: I can do that in 2 days apparently. Thanks!  

---

