Mapping the URL to method parameters |
[eluser]Unknown[/eluser]
Hi All, I just discovered CodeIgniter today, so you can imagine my giddiness. I am having trouble with one feature in particular and I would appreciate if someone could point me in the right direction. I have noticed that after specifying a correct controller/function, I can append anything and everything to the end of the URL. I am hoping there is a solution that will return a show_404 (or similar) if the number of arguments in the URL does not match the number of arguments on the method. This may not be possible with PHP5, but if it is, it seems like a viable solution to me. Thanks in advance, Matt
[eluser]Yash[/eluser]
404 error occurs automatically when function not found in controller. but if segments are missing in function argument then it is a warning and error by default. controller/function/seg1/seg2 error for first 2 segments i.e. controller and function warning for left 2 (or more) arguments.
[eluser]Colin Williams[/eluser]
'browse' below is a controller method Code: function browse($seg_1 = NULL, $seg_2 = NULL)
[eluser]Leonard Yulianus[/eluser]
[quote author="Colin Williams" date="1227107056"]'browse' below is a controller method Code: function browse($seg_1 = NULL, $seg_2 = NULL) haven't tested it but i think this solution gonna works... maybe you could just change the < into !=, to suit your condition better
[eluser]sophistry[/eluser]
_remap() would be a nice generalized way to do this. see http://ellislab.com/forums/viewthread/87496/ for two uses for _remap (one sent by Colin, one by me) :-) |
Welcome Guest, Not a member yet? Register Sign In |