4

Is anyone able to provide some advice on how these guys might have achieved their URL structure/naming? Is it done with template group names, plugins, both?

They are listed in the CartThrob gallery: http://www.chicathome.co.uk/

Looks like they get http://www.chicathome.co.uk/category/sub-category/product-name

Even their checkout pages have super simple URLs

PART A: We currently have for categories: http://www.domain.co.uk/template_group/template_name/ Be nicer to have http://www.domain.co.uk/category

And for products we currently have: http://www.domain.co.uk/template_group/template_name/url_title Be nicer to have http://www.domain.co.uk/category/url_title (and to have breadcrumbs of home > category > product title)

Plus they have products grouped into categories rather than all lumped in together. We have a playa field {product_category} for each product that says which categories the product needs to appear in - they can appear in more than one. Which also throws up how do you handle breadcrumbs for products that can appear in multiple areas?

PART B: Products can also be shopped for: by colour {by_colour}, and by occasion {by_occasion} - which are a playa field each in the product entry page of the EE CP.

So you'd want the following URL structure (and breadcrumbs of home > red > product title): http://www.domain.co.uk/red/url_title

I know this is probably EE related more than CT related. This is only my third EE site and first store. I just can’t get my head around how to get it all to work… wish we could take a peak under the hood of Chic at Home!

Does anyone have an example template group setup or similar that would demonstrate how I should be going about this?

Thanks for your time.

4 Answers 4

7

Ok, firstly, i would say that you really want URL's that when human read make sense and also work in a content & shop scenario, i'm not sure that having category as the first segment is optimal.

For example, a shop i have just developed has the url structure

example.com/shop/product/product_name

example.com/shop/category/category_name

This means that the user & the search engine are able to easily recognise by looking at the url where they are in the site. Also, it means that they can have example.com/blog and that is obviously separate from the shop as it's not preceded by "shop" in the URL.

Using this structure, you can have a template group of "shop" that allows you to have whatever templates you like and gives you lots of flexibility.

Alternatively, you can have:

example.com/product/product_name OR example.com/product/category/product_name

example.com/category/category_name

Which means you simply have your default template group with templates called "products" & "category" and then you can drive your content from there using if statements if needed to detect what is in the URL segments and show the content how you see fit.

With regards to how you handle breadcrumbs where products appear in multiple categories? Well, if you have the url structure i'm suggesting where you have example.com/category/category_name then as you go back in the segments, your template looks at the last url segment and shows all products that appear in that category. When you get right back to example.com/category you would show a page that lists all the categories.

If you are using playa fields for categorising, then you are going to need to do a fair amount of logic in your templates that works out what it should be showing dependent on the URL. So, if you have "category" as a url segment, then you can say if segment_2 == category, then segment_3 is the category itself and you use that value to pull in the data from your playa field to show products in that category.

There are, to be honest, a million different ways to do this. So my answer is right, but could also be wrong. It's up to you how you want your urls to work. My examples are simply personal preference.

With regards to your reference site, i imagine they've put loads of logic in the index template in their default template group or they've done some url routing with either the pages module or the structure add-on. Either way, i'm not mad keen on their url structure for a shop setup.

1
  • It's also worth considering that if you have the category in a product's URL you risk having canonical problems. For example, what if the product is in 2 or more categories? You would have multiple URLs for the same destination, which is probably easy to fix with a simple canonical meta tag, but totally avoidable. I would argue that in this instance KISS is the right way to go. /product/url_title/ and /category/category_name are self explanatory easy to read and short (less chance of being ...'ed on Google). SEO benefit here is little-to-none.
    – Mutual
    Nov 26, 2012 at 22:42
4

This URL schematic graphic is a great reference. Thanks to Jamessmith.co.uk:

ExpressionEngine URL Schematic

0
3

You might want to take a look at the Freeway add-on so you can use conventional EE templating techniques but then route them via different URLs:

https://github.com/averyvery/freeway

I've never used it before myself, but looks pretty good.

Otherwise, as John says, you'll need a whole heap of convoluted logic in your templates (which in turn will see you having problems with advanced conditionals, parse order and poor performance)

1
  • Thanks for the link, James. I'll check that out in the future. Cheers. Nov 26, 2012 at 4:21
2

@JohnWBaxter

Thanks very much for your help. I think I kind of prefer your second approach with having everything in the default template group as it takes out a URL segment from the display URL.

Does this sound right? …..in my default template group I could have templates:

  • index (homepage)
  • category
  • shop_by
  • product
  • cart
  • checkout
  • completed_order

PART A - GROUPING PRODUCTS: I could use my playa field {playa_categories} to group the product in their categories on the "category" template:

{exp:channel:entries channel="products" dynamic="no" search:playa_categories="{segment_2}" search:product_for_sale="y"}

example.com/category/bathroom

PART A - DISPLAY ACTUAL PRODUCT: A product listed on this category page would have a link to push to the 'product' template similar to:

example.com/product/{segment_2}/{product_url_title}

example.com/product/bathroom/towel

And on the product template I'd have:

{exp:channel:entries channel="products" url_title="{segment_3}" limit="1"}

And the breadcrumb on this page would be:

home >> example.com/category/{segment_2} >> example.com/category/{segment_2}/{segment_3}

home >> example.com/category/bathroom >> example.com/category/bathroom/towel

PART B - GROUP ALTERNATE WAYS TO FIND PRODUCT: I could use my playa fields {shop_colour}, {shop_types} to sort the types of groupings on the "shop_by" template:

{exp:channel:entries channel="products" dynamic="no" search:shop_colour="{segment_2}" search:shop_types="{segment_2}" search:product_for_sale="y"}

example.com/shop_by/{shop_colour}

example.com/shop_by/red

or

example.com/shop_by/{shop_types}

example.com/shop_by/glassware

PART B - DISPLAY ACTUAL PRODUCT: A product listed on this shop_by page would have a link to push to the 'product' template similar to:

example.com/product/{segment_2}/{product_url_title}

example.com/product/red/bowl

And on the product template I'd have:

{exp:channel:entries channel="products" url_title="{segment_3}" limit="1"}

And the breadcrumb on this page would be:

home >> example.com/shop_by/{segment_2} >> example.com/shop_by/{segment_2}/{segment_3}

home >> example.com/shop_by/red >> example.com/shop_by/red/bowl

I know that's a lot to take in - but am I on the right track?

Thanks very much for taking the time to help out :)

2
  • Well, theoretically, that looks pretty sound to me, i've not done it in that way before, but i don't see a problem with it. Just make sure that the product can only ever be reached using one url. So, if you have example.com/product/bathroom/towel just make sure that you couldn't also have example.com/product/home/towel, personally, i would always have example.com/product/towel as my url, as you don't need the categories in there, some products can be in two categories at once remember! Nov 27, 2012 at 13:47
  • Don't forget to tick my answer as the solution if you feel it is the right one for you! Cheers! Dec 4, 2012 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.