0

I have code which looks like

{exp:channel:entries channel="collection" category_group="5" category="{segment_2_category_id}" url_title="{segment_3}" status="open"}

I expect to retrive an entry from the channel named "collection" and with category ID# from category group ID#5, but what I'm getting is an entry (sometimes, it is based on segment_2) from category group ID#1. It looks like Low Seg2Cat is always pulling first category ID but not related to category group.

Category name/url title from segment_2 exists in another category group.

Any clue what is going on?

Thanks

2 Answers 2

3

There is a setting to restrict to Category Groups in Seg2Cat -- see the documentation. Note that, by default, Seg2Cat has this caveat:

If there are multiple categories with the same url_title, but in different groups, this extension will only return one of those. So best make sure your category url_titles are unique, or you select the relevant Category Groups in the settings so they are.

If you have the option of using another plugin, instead of Seg2Cat, you could use Cat2 (also on GitHub). Cat2 allows you to do this:

{exp:cat2:id category_url_title="{segment_2}" category_group="5"}
0
1

It seems the category url title's are not unique. Try making them unique and that should fix your issue as Low Seg2Cat queries the database and find the first match.

2
  • I know it can be solution, but does category title must to be unique? I thought that EE treats categories as IDs, so when I have specified category group I want to get categories (IDs) only from there. Anyway for SEO purposes I need to keep same subcategory titles in some instances. Apr 8, 2014 at 21:24
  • Low Seg2Cat creates early parsed global variables, which can be used anywhere, including in channel:entries tags, like you're doing. That means it has no way of knowing where or in what context the vars are going to be used. Setting the category_group param on a channel:entries tag does not influence the setting of global vars in any way.
    – Low
    Apr 9, 2014 at 6:16

Your Answer

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

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