CodeIgniter Forums
Routes question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Routes question (/showthread.php?tid=43603)



Routes question - El Forum - 07-18-2011

[eluser]Azrael91[/eluser]
My website loads pages from a 'webshop' class, with a 'pages' function, so the links are "website/webshop/pages/category". How can i change it to "website/category" ? Tried lots of ways from routes.php. Any ideea ?

Thanks


Routes question - El Forum - 07-18-2011

[eluser]Aken[/eluser]
Code:
$routes['(:any)'] = 'webshop/pages/$1';

You may want to reconsider having a single controller function serving all your pages, though. It makes your code more complicated, less compartmentalized and just more difficult in general.


Routes question - El Forum - 07-18-2011

[eluser]Azrael91[/eluser]
I'm using backendpro cms, and that's how it's structured Tongue. I tried what you said but it always takes me to the main index. As a matter of fact the URL is website.com/index.php/webshop/pages/category and it routes to website.com/index.php.


Routes question - El Forum - 07-18-2011

[eluser]Aken[/eluser]
Does your pages function have a redirect, where it sends you to the homepage if it fails to find something appropriate? If so, try disabling it and see if it still redirects you. If not, you know it's just an issue with the controller and you can narrow it down from there.


Routes question - El Forum - 08-04-2011

[eluser]Azrael91[/eluser]
[quote author="Aken" date="1310990056"]
Code:
$routes['(:any)'] = 'webshop/pages/$1';

You may want to reconsider having a single controller function serving all your pages, though. It makes your code more complicated, less compartmentalized and just more difficult in general.[/quote]

I don't know why it didn't work ar first ... now it does Smile. Another quick question:

This conflicts ... is there any other way ?
Code:
$route['(:any)'] = 'webshop/produse/$1';
$route['(:any)'] = 'webshop/pages/$1';



Routes question - El Forum - 08-04-2011

[eluser]Aken[/eluser]
The way routes work is that as soon as it finds a matching route, it will send it, regardless of what is after. So with that set up, your URLs will never route to webshop/pages/$1.

You need to differentiate between those two somehow. Like any "produse" calls will need to have something in the route to specify that it's a produse call.
Code:
$routes['produse/(:any)'] = 'webshop/produse/$1';
$routes['(:any)'] = 'webshop/pages/$1';



Routes question - El Forum - 08-04-2011

[eluser]Azrael91[/eluser]
Yeah ... I thought it might be like that Smile
Thanks