Showing specific category content as well as ALL I have a photography website with just two categories, 'Lifestyle' and 'Food'.

I have two problems:


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?


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
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 %}
    &lt;img src="{{ image.url }}"&gt;
{% 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() %}
    &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 %}


Hope that gets you going.