I have a setup in Craft 2 like below:
Section: products
Url format: flowers/{productCategory.last.uri}/{slug}
Categories:
cat1 = Bouquets
cat2 = Valentines days
Url format: flowers/{slug}
The problem headache arises when I want to get the entry URL within a category template. It always gets the last category of the entry due to the URL format. So once valentines day is added as a second category then a normal bouquet entry URL goes from this:
/flowers/bouquets/entry-slug
to
/flowers/valentines-day/entry-slug
I solved this partly by making my bouquet URL out of the URL path:
{% for entry in entries %}
{% set prodUrl = 'flowers/'~ seg2~ '/'~entry.slug %}
<a href="{{ baseUrl }}{{ prodUrl }}" >
However, the entry template now doesn't have the entry model.
How do other people solve this multiple categories for the same content type issue?