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.

  • I take it you mean Category 2.1 etc in the second group? – Low Jan 9 '14 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. – Peter Lewis Jan 9 '14 at 13:10
  • @Low Yeah sorry - Amended my answer. – Jason Mayo Jan 9 '14 at 14:14
  • @PeterLewis Yeah sorry - Amended my answer. – Jason Mayo Jan 9 '14 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. – Peter Lewis Jan 10 '14 at 8:41
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}
| improve this answer | |
  • 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 Jan 9 '14 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 Jan 9 '14 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 Jan 9 '14 at 16:52
  • 1
    Well, that's got custom add-on written all over it. :) – Low Jan 9 '14 at 17:06

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.