Hello!
Not a developer, so would like a bit of advice on figuring the URL structure, please!
I’m working on a site for a food wholesaler, so I want the URLs to read like so:
www.examplefoodretailer.com/products/meat/bacon www.examplefoodretailer.com/products/cheese/cheddar
I have a template group called ‘products’, of which /products/ is the index page which lists the high-level categories of food. /meat/ and /cheese/ are templates within this group, listing out the products in these categories.
‘Bacon’, ‘Cheddar’ etc are all entries within the ‘product’ channel, which is a content type to capture the details any individual product.
The documentation clearly explains how to create a URL structure two levels deep, such as www.examplefoodretailer.com/products/meat/, but I’m really unsure how to create the URL structure a level deeper, as I require.
Any advice, please?
Thanks!
Well, now I’m hungry!
But as to a solution- I personally prefer to go with the default url behavior because it saves me time, effort and thought.
Sometimes you don’t have a choice, though. In that case, you’ve got some options.
I’d probably ‘logic’ it and use Low’s Seg2Cat addon to help me pick apart the url.
So I’d use segment conditionals to figure out how many segments I have. I assume the second segment is always a category- correct? So I’d use Seg2Cat to find the category. If there’s a third segment then it’s either an entry url title or it’s a page indicator. Logic that out- if it’s a single entry, use the segment to set the url in the channel entry tag:
{exp:channel:entries url_title="{segment_3}” dynamic=”no” etc…}
If it was a category page, I’d have done:
{exp:channel:entries category="{segment_2_category_id}” dynamic=”no” etc…}
There are other options- you could use template routes or an add-on like Structure. But I’d personally just go with some segment logic and Seg2Cat.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.