routing wildcard help |
[eluser]simonCI[/eluser]
Hi! I'm following the tutorial -> http://ellislab.com/codeigniter/user-gui...ction.html and having problem with my wildcard. This is my code: Controller: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); model: Code: <?php routes.php: Code: $route['news/(:any)'] = 'site/view/$1'; // wrong here too? What looks wrong with my wildcard? I can access my index page, but not the view($slug) page,.... Any idea? Regards Simon
[eluser]Stefan Hueg[/eluser]
Your routes seem to be correct, but I noticed this little bug: Code: $data['news'] = $this->load->news_model->get_news($slug); ... which will always be empty / not set. Change it to Code: $data['news_item'] = $this->load->news_model->get_news($slug); And it should work
[eluser]CroNiX[/eluser]
[quote author="simonCI" date="1335640891"] Code: routes.php: First problem is on the first route, you didn't change it to "site", you left it as "news". Second problem is that "default_controller" and "404_override" need to come before all others. I know the tutorial shows it incorrectly, but in the user guide for URI Routing, it states that those 2 rules need to come before any wildcard/regex routes at the very bottom. Code: $route['default_controller'] = "site";
|
Welcome Guest, Not a member yet? Register Sign In |