<p>A simpler way to do this might be:</p>

<pre><code>{{ entry.type.name }}
</code></pre>

CC BY-SA 3.0
2018-02-22T18:38:18.553Z
this is the correct answer.
ricricucit
CC BY-SA 4.0
2022-04-29T02:38:48.410Z
There is also `entry.type.handle` which is a bit better for "code" checks.
Darryl Hein
CC BY-SA 3.0
2015-05-15T20:35:54.520Z
2015-05-15T20:35:54.520Z
Kirk Roberts
<p>Classic find the answer straight after posting.</p>

<p>The getEntryTypes method of the sections model allows you to choose how the array is indexed. This means you can do this:</p>

<pre><code>{% set entryTypes = section.getEntryTypes('handle') %}
</code></pre>

<p>Which means our entry type model can be accessed using:</p>

<pre><code>{% set entryType = entryTypes[routesEntryTypeHandle] %}
</code></pre>

<p>And the name:</p>

<pre><code>{{ entryType.name }}
</code></pre>

CC BY-SA 3.0
2014-08-12T17:03:52.427Z
2014-08-12T17:03:52.427Z
Jamie Pittock
<p>Each of my entry types have their own template. </p>

<p>The url is something like:</p>

<pre><code>/foo/{entryTypeHandle}
</code></pre>

<p>And the route is:</p>

<pre><code>'foo/(?P&lt;routesEntryTypeHandle&gt;[-\w]+)' =&gt; 'bar.html'
</code></pre>

<p>In the template I can get the section the entry type is in:</p>

<pre><code>{% set section = craft.sections.getSectionById(5) %}
</code></pre>

<p>And I can get ALL the entry types:</p>

<pre><code>{% set entryTypes = section.getEntryTypes() %}
</code></pre>

<p>And I can get all the entries of that entry type:</p>

<pre><code>{% set entries = craft.entries.section(section).type(routesEntryTypeHandle) %}
</code></pre>

<p>But I can't seem to get the entry type's name.</p>

<p>In the Sections Service there's a method called <code>getEntryTypesByHandle</code> but that's not available in the model.</p>

<p>I could get the entry type name from the <code>entries</code>, but that relies on there actually being results, which isn't assured.</p>

<pre><code>{{ entries.first.type.name }}
</code></pre>

<p>I must be missing an easier way. Anyone?</p>

<entry-type><sections>
How can you get an entry type's name from its handle in a template?
# How can you get an entry type's name from its handle in a template?

(Asked by: username_0 on 2014-08-12)

Each of my entry types have their own template. 
The url is something like:
/foo/{entryTypeHandle}

And the route is:
'foo/(?P[-\w]+)' => 'bar.html'

In the template I can get the section the entry type is in:
{% set section = craft.sections.getSectionById(5) %}

And I can get ALL the entry types:
{% set entryTypes = section.getEntryTypes() %}

And I can get all the entries of that entry type:
{% set entries = craft.entries.section(section).type(routesEntryTypeHandle) %}

But I can't seem to get the entry type's name.
In the Sections Service there's a method called getEntryTypesByHandle but that's not available in the model.
I could get the entry type name from the entries, but that relies on there actually being results, which isn't assured.
{{ entries.first.type.name }}

I must be missing an easier way. Anyone?

**Tags:** entry-type, sections


---

## 2 answers

### Answer by username_0 on 2014-08-12. Score: 10 | Accepted answer

Classic find the answer straight after posting.
The getEntryTypes method of the sections model allows you to choose how the array is indexed. This means you can do this:
{% set entryTypes = section.getEntryTypes('handle') %}

Which means our entry type model can be accessed using:
{% set entryType = entryTypes[routesEntryTypeHandle] %}

And the name:
{{ entryType.name }}


---

### Answer by username_1 on 2015-05-15. Score: 16

A simpler way to do this might be:
{{ entry.type.name }}

> **Comments:**
> **username_2**: this is the correct answer.  
> **username_3**: There is also `entry.type.handle` which is a bit better for "code" checks.  

---

