Welcome Guest, Not a member yet? Register   Sign In
URL Structuring help!
#1

[eluser]Sceneshift[/eluser]
Hi there,

Quite new to CI here, so forgive me for my ignorance.

I am developing an online store in CI and I want to structure my site like so:

http://www.myurl.com/jumpers/knitted/
-and then-
http://www.myurl.com/product_name/

Where jumpers is my category, knitted is a subcategory and product_name is a particular product. The problem I am having routing anything segment_1 to my controller called "category" which decides if we are looking at the category, a subcategory or a product page.

So I'd like my page to flow like so:

http://www.myurl.com/jumpers/ => Category controller -> Category View
http://www.myurl.com/jumpers/knitted => Category controller -> Sub Category View
http://www.myurl.com/product_name => Display controller -> Product View

I have two questions:

1. How do I route my urls like the in the example
2. I assume I am going to have to load the Category controller in product_name example... if so is it possible to call another controller from within another? I'd rather keep my category and display controllers seperate.

Oh! And as a side question, does anyone know which is better for SEO? http://www.mysite.com/category/product or http://www.mysite.com/product ??

Thanks!
#2

[eluser]richthegeek[/eluser]
You *could* do this with a lot of fancy regex'ing and ordering your routes in fancy ways, but if you add a category you will have a problem.

If you make products be in a sub directory, maybe

http://www.myurl.com/product/product_name then the whole routing issue shouldn't be a problem.
#3

[eluser]richthegeek[/eluser]
hmm actually if you routed :any to a controller which then searched for categories of that name and/or products of that name, redirecting appropriately... might be a bit query heavy though, so a more sane directory structure is a better bet.




Theme © iAndrew 2016 - Forum software by © MyBB