1

I have a strange issue, that I am hoping is something simple, and I'm just missing it.

I have two channels, that have different sets of categories.

In my first channel, I display what child cat it is in via GWcode categories.

{exp:gwcode_categories style="linear" last_only="yes" channel="walks" entry_id="{entry_id}"}

<span class="location"><i class="icon-location"></i> <a href="{path='walks/category/{cat_url_title}'}">{cat_name}</a></span>

{/exp:gwcode_categories}

This gives me the Url of domain.com/walks/category/categoryname

Then I have a template via Switchee, that displays these entries in this category. It uses segment 2 as the case value {category) and then displays the following channel entries tag.

{exp:channel:entries channel="walks" status="open|new" disable="member_data|category_fields" show_expired="yes" paginate="bottom" limit="10"}

{lv_walkdetails_main}
{lv_pagination}

{if switchee_no_results}

<p>Sorry, no results!</p>

{/if}

{/exp:channel:entries}

Now, as I said this displays all the entries that are listed within that category, however when I perform nearly exactly the same thing on another channel, "news", it displays every single entry, regardless as to whats in the URL.

Am I doing something wrong here? Whats the preferred way to showing a list of entries that belong to a certain child category?

1 Answer 1

2

From the looks of it, you have no category parameter set in the entries tag. So right now, the entries tag is listing all entries in the channel walks.

To make the entries tag dynamic based off the current category, I suggest using a addon like Low Seg2Cat or URL Helper (which I prefer for the extra helpful variables) to dynamically set the category parameter in the entries tag.

So, based off your example URL, the category name is in the third segment:

{exp:channel:entries 
    category="{segment_3_category_id}"
    channel="walks"
    disable="member_data|category_fields"
    dynamic="no"
    limit="10"
    paginate="bottom"
    show_expired="yes"
    status="open|new"
}
1
  • Ahhh! Brilliant! I've just gone in and realised I had Low Seg2Cat, and it was only set to work on the "walks" channel, hence walks was working and news not! Guess its taken a fair bit to familiarise myself with everything, bearing in mind it was built a year ago. Thanks for the help there! :)
    – shorn
    Commented Feb 8, 2013 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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