We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help with URL structure that's three levels deep

How Do I?

aaronboland's avatar
aaronboland
4 posts
4 years ago
aaronboland's avatar aaronboland

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!

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
4 years ago
Robin Sowell's avatar Robin Sowell

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.

       
aaronboland's avatar
aaronboland
4 posts
4 years ago
aaronboland's avatar aaronboland

Hi Robin. Many apologies for only just getting back to you. Just wanted to say thanks for taking the time to give me this advice - it was really helpful. Cheers!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.