Welcome Guest, Not a member yet? Register   Sign In
Routes and simple craigslist esque categories
#4

[eluser]helmutbjorg[/eluser]
In my applications I put an extra field in the database table like so

categories
----------
id
name
url_name
parent_id

Where url_name is the strtolower and url_title of the name. Some people refer to this field as the slug. That way you can search on it and still display the actual name.

However to search for unique values you may need to include the id in with the name in the url and then explode the parts out. For example

Code:
mysite.com/123-appliances/8782-stovetops

Then the first part of each category is always the id and you can use that to search for the products. However this makes it appear a little less clean but will still be good for seo.

One other way is to search on the parent too (event if the category doesn't have one). And disallow users from adding two categories with the same name to the one parent. This way you keep your urls clean and can be certain you are finding the correct category.

For the example above your search query would be like:

Code:
Find the category with the url_name 'stovetops' who has a parent with a url_name of 'appliances'

Obviously you would join the table to itself via the parent_id so you can search on the parents url_name.

Hope that helps.


Messages In This Thread
Routes and simple craigslist esque categories - by El Forum - 03-06-2010, 01:44 AM
Routes and simple craigslist esque categories - by El Forum - 03-06-2010, 03:05 AM
Routes and simple craigslist esque categories - by El Forum - 03-06-2010, 12:24 PM
Routes and simple craigslist esque categories - by El Forum - 03-06-2010, 12:44 PM
Routes and simple craigslist esque categories - by El Forum - 03-07-2010, 02:38 AM
Routes and simple craigslist esque categories - by El Forum - 03-07-2010, 03:12 AM
Routes and simple craigslist esque categories - by El Forum - 03-08-2010, 01:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB