CodeIgniter Forums
problem with routing and passing arguments - 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: problem with routing and passing arguments (/showthread.php?tid=58332)



problem with routing and passing arguments - El Forum - 06-03-2013

[eluser]murichej[/eluser]
i want to acces to archive controller, which is in folder "front". for example: archive/2013/05

so i got this:

routes.php:
Quote:$route['archive/(:num)/(:num)'] = "front/archive/$1/$2";

controller front/archive.php:

1.
Quote:public function index()
it's working but need to access to arguments via uri->segment()


2.
Quote:public function index($a)
it's working but obviously i get only first parameter


3.
Quote:public function index($a, $b)
i get an error: "Message: Missing argument 2 for Archive::index()"


i have no idea what is happening. 3rd choice should work in my opinion. i can't understand why 2nd choice is working but 3rd doesn't.


problem with routing and passing arguments - El Forum - 06-03-2013

[eluser]CroNiX[/eluser]
In your route, try including the index method.
Code:
$route[‘archive/(:num)/(:num)’] = “front/archive/index/$1/$2”;



problem with routing and passing arguments - El Forum - 06-03-2013

[eluser]murichej[/eluser]
tried. if I do this I don't even get 1st argument


problem with routing and passing arguments - El Forum - 06-03-2013

[eluser]CroNiX[/eluser]
Try using a different method other than index. Index is meant to be used when NO parameters are sent, including the method name.