<p>OK I finally figured it out. Thanks Ben.</p>

<pre><code>{% for template in entry.chooseTemplateExample %}

  &lt;a href="{{ template.url }}" class="btn btn-primary"&gt;View {{ template.title }} example&lt;/a&gt;&lt;br&gt;

  {% for block in template.chooseComponentForTemplate %}

     {% for component in block.component %}
            {{ component.title }}
     {% endfor %}

  {% endfor %}

{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-04-04T18:59:20.383Z
2016-04-04T18:59:20.383Z
julzmon
<p>When you loop through your matrix, you're missing the <code>s</code> on <code>components</code>. Should be:</p>

<pre><code>{% for block in template.components %}
</code></pre>

<p>Each item in that loop will be one of the blocks in the matrix. So then you can call <code>{{ block.component }}</code> directly.</p>

<p>FYI, in your code, it looks like that <code>component</code> field in the matrix block is loopable as well? If you're trying to loop through an entries field, and then loop through a matrix field per entry, and then loop through another field per matrix block, expect some serious performance issues.</p>

<p>Full code reference: </p>

<pre><code>{% for template in entry.chooseTemplateExample %}
  &lt;a href="{{ template.url }}" class="btn btn-primary"&gt;View {{ template.title }} example&lt;/a&gt;&lt;br&gt;

  {% for block in template.components %}
    {% for component in block.component %} {!-- Is this field really loopable? --}
      {{ title }}
    {% endfor %}
  {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-04-04T18:52:27.443Z
Thanks for the reply Ben. I updated my question as I mistyped. I do have a matrix block called `component` with an Entry field `component`. I'm trying to get the title of this Entry field `component`.
julzmon
CC BY-SA 3.0
2016-04-04T18:53:48.200Z
I'm getting the following error "Craft\EntryModel and its behaviors do not have a method or closure named "component"."
julzmon
CC BY-SA 3.0
2016-04-04T18:20:04.853Z
2016-04-04T18:20:04.853Z
Ben Wilkins
<p>I'm trying to retrieve matrix content from a an Entry field <code>chooseTemplateExample</code> which has a matrix block <code>component</code> with a Entry field <code>component</code>.</p>

<pre><code>{% for template in entry.chooseTemplateExample %}
  &lt;a href="{{ template.url }}" class="btn btn-primary"&gt;View {{ template.title }} example&lt;/a&gt;&lt;br&gt;

  {% for block in template.component %}

     //Trying to get the matrix content within this "template"
     {% for block in entry.chooseComponentForTemplate %}
      {% for component in block.component %}
        {{ title }}
      {% endfor %}
    {% endfor %}

  {% endfor %}

{% endfor %}
</code></pre>

<p>Thank you in advance.</p>

<matrix>
Retrieve matrix content from Entries form field in an Entry
# Retrieve matrix content from Entries form field in an Entry

(Asked by: username_0 on 2016-04-04)

I'm trying to retrieve matrix content from a an Entry field chooseTemplateExample which has a matrix block component with a Entry field component.
{% for template in entry.chooseTemplateExample %}
  View {{ template.title }} example

  {% for block in template.component %}

     //Trying to get the matrix content within this "template"
     {% for block in entry.chooseComponentForTemplate %}
      {% for component in block.component %}
        {{ title }}
      {% endfor %}
    {% endfor %}

  {% endfor %}

{% endfor %}

Thank you in advance.

**Tags:** matrix


---

## 2 answers

### Answer by username_0 on 2016-04-04. Score: 1

OK I finally figured it out. Thanks Ben.
{% for template in entry.chooseTemplateExample %}

  View {{ template.title }} example

  {% for block in template.chooseComponentForTemplate %}

     {% for component in block.component %}
            {{ component.title }}
     {% endfor %}

  {% endfor %}

{% endfor %}


---

### Answer by username_1 on 2016-04-04. Score: 1

When you loop through your matrix, you're missing the s on components. Should be:
{% for block in template.components %}

Each item in that loop will be one of the blocks in the matrix. So then you can call {{ block.component }} directly.
FYI, in your code, it looks like that component field in the matrix block is loopable as well? If you're trying to loop through an entries field, and then loop through a matrix field per entry, and then loop through another field per matrix block, expect some serious performance issues.
Full code reference: 
{% for template in entry.chooseTemplateExample %}
  View {{ template.title }} example

  {% for block in template.components %}
    {% for component in block.component %} {!-- Is this field really loopable? --}
      {{ title }}
    {% endfor %}
  {% endfor %}
{% endfor %}

> **Comments:**
> **username_0**: Thanks for the reply Ben. I updated my question as I mistyped. I do have a matrix block called `component` with an Entry field `component`. I'm trying to get the title of this Entry field `component`.  
> **username_0**: I'm getting the following error "Craft\EntryModel and its behaviors do not have a method or closure named "component"."  

---

