<p>From your example, it is a bit hard to tell how your site is organized, but it sounds like you want to set up content specific to each ministry (which is stored in the top-level of your "site_content" structure?), which will be shared across all of that ministry's sub-pages. Regardless, you will essentially want to retrieve the entry where the slider data is stored, and loop through the matrix data from there.</p>

<pre><code>{% if craft.request.segment(2) == "crosstrainers" %}
    {% set entry = craft.entries.section('site_content').slug('crosstrainers') %}
    {% for block in entry.slider %}
        {# prevent error if no slider image is defined #}
        {% if block.sliderImage|length %}
            {% set image = block.sliderImage.first() %}
            &lt;img class="slider-image" src="{{ image.getUrl }}" alt="{{ entry.title }}" /&gt;
            ...
        {% endif %}
    {% endfor %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-06-25T19:38:34.683Z
Douglas, thank you.  I didn't give you enough information, sorry about that, but you did help me see what I was doing wrong.  Working perfect.  Thank you again.
user1663102
CC BY-SA 3.0
2015-06-25T17:36:02.770Z
2015-06-25T17:36:02.770Z
Douglas McDonald
<p>I am new to Craft and have a decent handle on the basics, but I am struggling a little getting this to work.  Here is what I would like to do:</p>

<p>I have a banner with bxslider which will be looping through images in a matrix field.  This is for a church site and this template will be used for all their ministries.  Each ministry will have it's own photos, but right now assets is returning images for all entries.</p>

<p>Here is my code:</p>

<pre><code>{% elseif craft.request.segment(2) == "crosstrainers" %}

&lt;div class="banner-slider-block"&gt;

    &lt;ul class="banner-slider-list"&gt;

        {% for entry in craft.entries
            .section('site_content')
            .find() 
        %}

        {% for block in entry.slider %}     
        &lt;li&gt;

            &lt;div class="banner-slide-block"&gt;

                    {% for image in block.sliderImage.limit(1) %}
                        &lt;img class="slider-image" src="{{ image.getUrl }}" alt="{{ entry.title }}" /&gt;
                    {% endfor %}

                    &lt;div class="page-wrapper"&gt;

                        &lt;div class="slider-text-box {{ block.sliderTextBoxLocation }}"&gt;

                            &lt;h3 class="slider-header"&gt;{{ block.sliderHeader}}&lt;/h3&gt;

                            &lt;p class="slider-text"&gt;{{ block.sliderText}}&lt;/p&gt;

                            &lt;a class="slider-button" href=""&gt;&lt;div class="linked-button"&gt;{{ block.sliderButtonText}}&lt;/div&gt;&lt;/a&gt;

                        &lt;/div&gt;

                    &lt;/div&gt;          

            &lt;/div&gt;

        &lt;/li&gt;
        {% endfor %}

        {% endfor %}

    &lt;/ul&gt;

&lt;/div&gt;
</code></pre>

<p>Any suggestions on how to limit the asset results to each ministry.</p>

CC BY-SA 3.0
2015-06-25T15:33:59.857Z
are you trying to get the first image from an asset field? are you looking for this? `{% set image = block.sliderImage.first() %}{{image.url}}`
Luke Holder
<assets><categories>
Using categories to filter assets
# Using categories to filter assets

(Asked by: username_0 on 2015-06-25)

I am new to Craft and have a decent handle on the basics, but I am struggling a little getting this to work.  Here is what I would like to do:
I have a banner with bxslider which will be looping through images in a matrix field.  This is for a church site and this template will be used for all their ministries.  Each ministry will have it's own photos, but right now assets is returning images for all entries.
Here is my code:
{% elseif craft.request.segment(2) == "crosstrainers" %}



    

        {% for entry in craft.entries
            .section('site_content')
            .find() 
        %}

        {% for block in entry.slider %}     
        

            

                    {% for image in block.sliderImage.limit(1) %}
                        
                    {% endfor %}

                    

                        

                            {{ block.sliderHeader}}

                            {{ block.sliderText}}

                            {{ block.sliderButtonText}}

                        

                              

            

        
        {% endfor %}

        {% endfor %}

    



Any suggestions on how to limit the asset results to each ministry.

**Tags:** assets, categories

> **Comments:**
> **username_1**: are you trying to get the first image from an asset field? are you looking for this? `{% set image = block.sliderImage.first() %}{{image.url}}`  

---

## 1 answers

### Answer by username_2 on 2015-06-25. Score: 1

From your example, it is a bit hard to tell how your site is organized, but it sounds like you want to set up content specific to each ministry (which is stored in the top-level of your "site_content" structure?), which will be shared across all of that ministry's sub-pages. Regardless, you will essentially want to retrieve the entry where the slider data is stored, and loop through the matrix data from there.
{% if craft.request.segment(2) == "crosstrainers" %}
    {% set entry = craft.entries.section('site_content').slug('crosstrainers') %}
    {% for block in entry.slider %}
        {# prevent error if no slider image is defined #}
        {% if block.sliderImage|length %}
            {% set image = block.sliderImage.first() %}
            
            ...
        {% endif %}
    {% endfor %}
{% endif %}

> **Comments:**
> **username_0**: Douglas, thank you.  I didn't give you enough information, sorry about that, but you did help me see what I was doing wrong.  Working perfect.  Thank you again.  

---

