Welcome Guest, Not a member yet? Register   Sign In
Codeigniter routing
#1

[eluser]Unknown[/eluser]
Hello,

I working on a webshop project. And want to use search friendly url's.
So I want to check the database if there is a match for a category, product or page.
I could save a cache file with the routes to controllers that can be loaded in the routes.php file. But the $route array could be more then 10.000 items. Is that a good way to handle this?

Or is there an other way to do this?

Thanks already

Sorry for my bad english..
Best regards,

Patrick
#2

[eluser]masrodjie[/eluser]
Why you need so many re-map URI in route.php ?
In the route.php let you to use regular expression.
I think the performance will be slow when there are ten thousands re-map URI since it using regex to parse.
#3

[eluser]Pert[/eluser]
Depending on how exactly do you want to set up your URLs, you can use routing file if all your links follow some kind of a standard
Code:
$route['category/(:any)'] = 'category/details/$1';

So URL example.com/category/my-new-category loads controller category and runs method details with single attribute with value 'my-new-category'. From there you can see if that value is in your category table.

You can also use controllers _remap function. If present, when ever controller is called, only _remap function is called. You can check in that method what kind of link it is.

I myself use 404 override in route configuration file for my CMS. If URL does not translate to a meaningful controller, my custom 404 controller tries to figure out, what content is suppose to be shown, and displays it - or if it can't work out URL, it truely is a 404 page.




Theme © iAndrew 2016 - Forum software by © MyBB