<p>It sounds like you're pretty close. I'll work off of the assumption that you want the URLs to be structured like this:</p>

<p>/images</p>

<p>/lifestyle</p>

<p>/food</p>

<p>…and an individual image will be at /images/{image slug}.</p>

<p>Like you've done, I'd create a category group called <strong>photoGalleries</strong>. I'd set the URL format simple to <code>/{slug}</code> and a max level of 1. The two categories can then be added to that.</p>

<p>The <strong>images</strong> channel would have a URL format of <code>/images/{slug}</code>.</p>

<p>By setting up categories and the channel like this, Craft will automatically create variables when it matches those paths. You can then use these variables to do practical things.</p>

<p>To show images by category, you'll need to use to <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow"><code>.relatedTo()</code></a> method. When Craft matches a category route, it will create a <code>category</code> <a href="http://buildwithcraft.com/docs/templating/categorymodel" rel="nofollow">variable</a> which can be passed into this method. In the template for a category, you'll need code like this:</p>

<pre><code>{% set images = craft.entries.section('images').relatedTo(category).find() %}
{% for image in images %}
    &lt;img src="{{ image.url }}"&gt;
{% endfor %}
</code></pre>

<p>This asks Craft to find any image which has been categorised by (related to) a specific category.</p>

<p>You can then create a simple images listing via a template for <code>/images</code>. If you wanted to get really fancy, you could output what categories an image is under. To do that you'd need code like this.</p>

<pre><code>{% for image in craft.entries.images.find() %}
    &lt;img src="{{ image.url }}"&gt;

    &lt;ul&gt;
    {% for category in craft.categories.relatedTo(image).find() %}
        &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

<p>Hope that gets you going.</p>

CC BY-SA 3.0
2014-08-04T15:33:15.167Z
2014-08-04T15:33:15.167Z
Stuart Whitehead
<p>Apologies for the "Answer" but the comments have a way too short character restriction...</p>

<p>I've been away for a few days so only just getting back to this.  I'm still not getting any content pulled through following your suggestion.  I've even gone back to a clean slate (install) but still struggling.</p>

<p>Just to clarify:
I (now) have a Category group called "<em>stmimagecategories</em>".
I have assigned an Asset field to this group called "<em>imageUpload</em>".
I have created a Category field called "<em>imageCategory</em>".</p>

<p>My '<strong>Section</strong>' is called '<strong>Gallery</strong>' and I have assigned the '<em>imageCategory</em>' field to that section.</p>

<p>I imagine the clients workflow would be to use the '<strong>Categories</strong>' menu and subsequent Modal to dump a load of images into the appropriate category using the '<em>imageUpload</em>' field.</p>

<p>So, what I need is... User creates a new Gallery <strong>entry</strong> called say "Panoramas".  They add a title, bit of descriptive text and then select 'Panoramas' from the '<em>imageCategory</em>' field.</p>

<p>I have the above set-up but the required template syntax to pull the content of the "<em>imageCategory</em>" field is blowing my mind :(</p>

<p>Further, the 'page needs to know what to show based on URL.</p>

<p>If you can help further with this I would be very much appreciate it.</p>

CC BY-SA 3.0
2014-08-11T18:13:56.407Z
2014-08-11T18:13:56.407Z
Martin
<p>I have a photography website with just two categories, 'Lifestyle' and 'Food'.</p>

<p>I have two problems:</p>

<ol>
<li>How to display the content</li>
</ol>

<p>I have a category group called 'photoCategories' to which I have assigned two categories 'Lifestyle' and 'Food'.  I also have a Category field 'imageCategory'.</p>

<p>At the moment I have two Entries, one for Lifestyle and one for Food and I have linked to the appropriate category in the category field.</p>

<p>I have a 'category' template but I can't figure how to pull the appropriate content based on the URI and how to pull All content (within) the category group for when the user selects All?</p>

<ol>
<li>My navigation needs to look as follows:</li>
</ol>

<p>Homepage (Single)
All Images ('images' Channel)
Lifestyle Photos ('images' Channel)
Food Photos ('images' Channel)
About Us (Single)
Contact Us (Single)</p>

<p>Any advice is very much appreciated.</p>

<p>Thanks</p>

<p>Martin</p>

<templating><categories><navigation>
Showing specific category content as well as ALL
# Showing specific category content as well as ALL

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

I have a photography website with just two categories, 'Lifestyle' and 'Food'.

I have two problems:

1. How to display the content

I have a category group called 'photoCategories' to which I have assigned two categories 'Lifestyle' and 'Food'. I also have a Category field 'imageCategory'.

At the moment I have two Entries, one for Lifestyle and one for Food and I have linked to the appropriate category in the category field.

I have a 'category' template but I can't figure how to pull the appropriate content based on the URI and how to pull All content (within) the category group for when the user selects All?

1. My navigation needs to look as follows:

Homepage (Single)
All Images ('images' Channel)
Lifestyle Photos ('images' Channel)
Food Photos ('images' Channel)
About Us (Single)
Contact Us (Single)

Any advice is very much appreciated.

Thanks

Martin

**Tags:** templating, categories, navigation

---

## 2 answers

### Answer by username_1 on 2014-08-04. Score: 3

It sounds like you're pretty close. I'll work off of the assumption that you want the URLs to be structured like this:
/images
/lifestyle
/food
…and an individual image will be at /images/{image slug}.
Like you've done, I'd create a category group called photoGalleries. I'd set the URL format simple to /{slug} and a max level of 1. The two categories can then be added to that.
The images channel would have a URL format of /images/{slug}.
By setting up categories and the channel like this, Craft will automatically create variables when it matches those paths. You can then use these variables to do practical things.
To show images by category, you'll need to use to .relatedTo() method. When Craft matches a category route, it will create a category variable which can be passed into this method. In the template for a category, you'll need code like this:
{% set images = craft.entries.section('images').relatedTo(category).find() %}
{% for image in images %}
    
{% endfor %}

This asks Craft to find any image which has been categorised by (related to) a specific category.
You can then create a simple images listing via a template for /images. If you wanted to get really fancy, you could output what categories an image is under. To do that you'd need code like this.
{% for image in craft.entries.images.find() %}
    

    
    {% for category in craft.categories.relatedTo(image).find() %}
        {{ category }}
    {% endfor %}
    
{% endfor %}

Hope that gets you going.


---

### Answer by username_0 on 2014-08-11. Score: 0

Apologies for the "Answer" but the comments have a way too short character restriction...

I've been away for a few days so only just getting back to this. I'm still not getting any content pulled through following your suggestion. I've even gone back to a clean slate (install) but still struggling.

Just to clarify:
I (now) have a Category group called "*stmimagecategories*".
I have assigned an Asset field to this group called "*imageUpload*".
I have created a Category field called "*imageCategory*".

My '**Section**' is called '**Gallery**' and I have assigned the '*imageCategory*' field to that section.

I imagine the clients workflow would be to use the '**Categories**' menu and subsequent Modal to dump a load of images into the appropriate category using the '*imageUpload*' field.

So, what I need is... User creates a new Gallery **entry** called say "Panoramas". They add a title, bit of descriptive text and then select 'Panoramas' from the '*imageCategory*' field.

I have the above set-up but the required template syntax to pull the content of the "*imageCategory*" field is blowing my mind :(

Further, the 'page needs to know what to show based on URL.

If you can help further with this I would be very much appreciate it.


---

