Welcome Guest, Not a member yet? Register   Sign In
problem with routing and passing arguments
#1

[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.
#2

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

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB