Routes problem |
Hi,
I have those routes defined: Code: $routes->add('registracija', 'Pers/Registracija::index'); now I want to add this Code: $routes->add('korisnik/admin/urediFeed/(:num)', 'Pers/UserAdministracija::urediFeed/$1'); but when I add it, I always get 404 - File Not Found with some controller that I even don't have. If you remove (:num) (and remove argument from method) it works so it is 100% something with routes and not with method and controller.
Please show the exact 404 message including "some controller that I don't have."
Just a guess, but I suspect you have not used namespace correctly. (06-14-2020, 08:41 AM)dave friend Wrote: Please show the exact 404 message including "some controller that I don't have."So if i try to access that route with: korisnik/admin/urediFeed/22 I get this: Quote:Controller or its method is not found: \App\Controllers\Pers::index It should not be namespace, because when I remove (:num) and $1, that route opens file from view which should be opened before with (:num) and $1 in route definition. EDIT: I decided to test this route with this: I added (:num) in URI part and removede $1 from "right side" parameter, and it worked. But as soon as I add .... 'Pers/UserAdministracija::urediFeed/$1', it stop working. So am I passing $1 in correct way to my method "urediFeed" or what?
Just out of curiosity, what happens if you change (:num) to (:any), and move the new route between the lines:
Code: $routes->add('korisnik/promjenaPodataka', 'Pers/UserProfil::promjenaPodatakaPotvrdi'); (06-14-2020, 11:46 AM)burgoyn1 Wrote: Just out of curiosity, what happens if you change (:num) to (:any), and move the new route between the lines: Same thing I did found solution but it didn't resolve actual problem... Instead of passing $1 to method urediFeed, now that method is not accepting any value but inside of it I decode URI segments and take 4th... PHP Code: // Change to the below What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
This is wrong:
PHP Code: $routes->add('korisnik/admin/urediFeed/(:any)', 'Pers/UserAdministracija::urediFeed/$1'); Should be: PHP Code: $routes->add('korisnik/admin/urediFeed/(:any)', 'Pers\UserAdministracija::urediFeed/$1'); Namespaces use a back slash not a forward slash. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |