<p>Well done for working out how to display "reverse-related" entries!</p>

<p>In order to separate your Articles into two lists i.e.</p>

<ol>
<li>Articles with downloads</li>
<li>Articles without downloads</li>
</ol>

<p>... I would do something like the following on your Company single-entry template...</p>

<pre><code>{% set relatedArticles = craft.entries.section('article').relatedTo() %}

{# Related articles which have downloads #}
{% for articleEntry in relatedArticles %}

    {# check for Matrix content #}
    {% if articleEntry.downloads != '' %}
        &lt;h3&gt;{{ articleEntry.title }}&lt;/h3&gt;

        &lt;ul&gt;
            {# loop through any matrix items #}
            {% for block in articleEntry.downloads %}

                {# get the first asset into a variable named 'download' #}
                {% set download = block.downloadFile.first() %}

                &lt;li&gt;&lt;a href="{{ siteUrl }}{{ download.url }}"&gt;{{ block.downloadName }}&lt;/a&gt;&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;

    {% endif %}
{% endfor %}

{# Articles which do not have downloads #}
{% for articleEntry in allArticles %}

    {# check for blank Matrix content #}
    {% if articleEntry.downloads == '' %}

        {# display article titles #}
        &lt;h3&gt;{{ articleEntry.title }}&lt;/h3&gt;

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

<p>Hope that helps. Let us know how you get on...</p>

CC BY-SA 3.0
2016-06-28T14:18:08.050Z
Thank you. I am going to write up this code and see if I get the desired results. I will definitely update you and mark this as an answer once I get this working.
Subrato M
CC BY-SA 3.0
2016-06-28T13:22:07.897Z
2016-06-28T13:22:07.897Z
Matt P
<p>I have a channel which is basically a list of articles. Each article is associated with one or more companies. When I click on companies I want to show all  the articles related to the company. I got that working, but now I want to show all the articles which have download types inside of them. So I had created a Matrix field type. I want to search for articles which will return all the articles which have those and then exclude them from other list which won't have any download association. </p>

<p>Is this doable?</p>

<matrix><categories><channels>
How to get data from Matrix field type?
# How to get data from Matrix field type?

(Asked by: username_0 on 2016-06-17)

I have a channel which is basically a list of articles. Each article is associated with one or more companies. When I click on companies I want to show all the articles related to the company. I got that working, but now I want to show all the articles which have download types inside of them. So I had created a Matrix field type. I want to search for articles which will return all the articles which have those and then exclude them from other list which won't have any download association.

Is this doable?

**Tags:** matrix, categories, channels


---

## 1 answers

### Answer by username_1 on 2016-06-28. Score: 1

Well done for working out how to display "reverse-related" entries!
In order to separate your Articles into two lists i.e.

Articles with downloads
Articles without downloads

... I would do something like the following on your Company single-entry template...
{% set relatedArticles = craft.entries.section('article').relatedTo() %}

{# Related articles which have downloads #}
{% for articleEntry in relatedArticles %}

    {# check for Matrix content #}
    {% if articleEntry.downloads != '' %}
        {{ articleEntry.title }}

        
            {# loop through any matrix items #}
            {% for block in articleEntry.downloads %}

                {# get the first asset into a variable named 'download' #}
                {% set download = block.downloadFile.first() %}

                {{ block.downloadName }}
            {% endfor %}
        

    {% endif %}
{% endfor %}

{# Articles which do not have downloads #}
{% for articleEntry in allArticles %}

    {# check for blank Matrix content #}
    {% if articleEntry.downloads == '' %}

        {# display article titles #}
        {{ articleEntry.title }}

    {% endif %}
{% endfor %}

Hope that helps. Let us know how you get on...

> **Comments:**
> **username_0**: Thank you. I am going to write up this code and see if I get the desired results. I will definitely update you and mark this as an answer once I get this working.  

---

