1

I've always had this problem with categories in EE. I want to be able somehow to specify which categories show in the URL & a custom breadcrumb setup I've created.

For example, if I had the following setup...

Category Group 1
Category 1.1
Category 1.2
Category 1.3
Category 1.4

Category Group 2
Category 2.1
Category 2.2
Category 2.3
Category 2.4

Both assigned to a channel called "Products". Now every time I create a product I can choose which category the product goes in to.

For example...

Product 1, will go in Category 1.1, Category 1.2 and Category 2.4

But when I output the categories and limit it to just 2 in the URL doing something like...

{site_url}products/{categories limit="2"}{category_url_title}/{/categories}/{url_title}

It would also pick up on the first two categories category...

http://website.com/products/category-1-1/category-1-2/product-name

Is there anyway to make it specify which category to show?

This is an issue for one of our clients because they have MANY category groups and assign products to many categories. So if the groups were...

Group 1
Group 2
Group 3
Group 4

It still only displays the categories in the URL from Group 1, none of the others. Ideally this would help the SEO and the make the URL's make more sense if they could specify which categories appear in the URL.

5
  • I take it you mean Category 2.1 etc in the second group?
    – Low
    Commented Jan 9, 2014 at 9:57
  • Jason can you revisit your question as it doesn't make sense in the examples (/category-1-1/category-1-1/product-name) and specify exactly what you are trying to achieve as it's not obvious - example output and the expected rules you'd like applied. Commented Jan 9, 2014 at 13:10
  • @Low Yeah sorry - Amended my answer.
    – Jason Mayo
    Commented Jan 9, 2014 at 14:14
  • @PeterLewis Yeah sorry - Amended my answer.
    – Jason Mayo
    Commented Jan 9, 2014 at 14:14
  • I still don't know what you're expecting, you mention: "Product 1, will go in Category 1.1, Category 1.2 and Category 2.4" but what in that example would be the URL you want. Is it that you want 1 category out of each group, and if so, which category should be chosen? First it finds? Once we know the rules as to which categories should be chosen and why, we may be able to help further. Commented Jan 10, 2014 at 8:41

1 Answer 1

2

If, as per your example, you only want to show categories from a certain group, you can use the show_group="" parameter on the {categories} variable pair. Creating the URLs would then look something like...

/products{categories show_group="1"}/{category_url_title}{/categories}/{url_title}
4
  • I have done this, but if they add other groups it doesn't work because I need to add the group ID's in.
    – Jason Mayo
    Commented Jan 9, 2014 at 16:06
  • 1
    You're letting the end user add category groups, and you want to create URLs using category_url_titles from that new group? Yeah, that might prove difficult. Personally, I wouldn't recommend that in the first place, tho.
    – Low
    Commented Jan 9, 2014 at 16:14
  • Yeah, thats it - it's very rare we get this problem because not many clients want to edit the groups. I'm wondering whether theres a way of letting them create the URL within the entry in the CMS (With the categories in it)...
    – Jason Mayo
    Commented Jan 9, 2014 at 16:52
  • 1
    Well, that's got custom add-on written all over it. :)
    – Low
    Commented Jan 9, 2014 at 17:06

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.