Welcome Guest, Not a member yet? Register   Sign In
Creating Clean URLS
#1

[eluser]macleodjb[/eluser]
I have an older article website that i want to convert over with codeigniter. My old urls are based off of the category and subcategory like this.

www.example.com/business
www.example.com/business/technology


if business if shown if will get all articles in that category.

Can this be done using a route? or is there a better way of doing it?
#2

[eluser]Alexander Obenauer[/eluser]
just make your controllers the categories.

Example: you have a controller business.

the index function will call a view and send it all of the articles. the technology function will call a view and send it only the tech articles.
#3

[eluser]macleodjb[/eluser]
Thanks but that's not the answer i was looking for. What you're telling me is that i should have a controller for each category on my site, all with the same code inside but a different name. So if i have 200 categories i will have 200 controllers, and if i want to make an edit to how it is displayed i have to edit 200 files individually. I'm sorry but that method doesn't seem very prudent.

If there is not another way to do this then i'll leave it alone.
#4

[eluser]Alexander Obenauer[/eluser]
I did not realize you may have so many categories. Please be specific next time. Also, changing it would just be changing the view file they all call.

Anyways, I would just use .htaccess to rerout /categoryname to be /controller/function/categoryname and grab the 3rd segment and fourth for subcat.




Theme © iAndrew 2016 - Forum software by © MyBB