0

I have a masonry style setup for a portfolio page and would like to allow the client to chose multiple categories per portfolio entry. The issue I'm having is each entry is displaying multiple times in the 'Show All' section when more than one category is being selected.

Here is the basic markup I have for the portfolio section—

{exp:channel:entries channel="projects"}
{categories}
    <div class="element clearfix col1-3 portfolio {category_name}">
        <a href="{title_permalink='projects/index'}" title="">
            <figure><img src="{project_image:project_thumb}"/></figure>
        </a>
    </div>
{/categories}
{/exp:channel:entries}

Here's an image of what's showing on the 'Show All' section. The two items at the bottom are in more than one category, but I'd only like one to show.—

enter image description here

Thanks in advance.

0

Summary: you should be using the category parameter in the channel entries loop.

Longer answer:

The issue here is that you're displaying your entries within the {categories} tag pair; the typical use-case of {categories} is to build a category list, just like you have in the first tile of your layout.

{exp:channel:entries channel="projects"}
    {categories}... this gets looped through multiple times ... {categories}
{exp:channel:entries}

I suggest installing URL Helper, which would allow you to have a URL like example.com/portfolio/education - URL Helper will then give you the category ID of segment 2 - {segment_2_category_id} - which you can use as the parameter in your channel entries loop.

{exp:channel:entries channel="projects" dynamic="no" category="{segment_2_category_id}"}
    {!-- channel fields here, without any {categories} tags --}
{exp:channel:entries}
1
  • Thanks for this, I will give it a go and let you know how I get on.
    – Elliot
    Aug 19 '15 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.