I hope this is not a bug! |
[eluser]Fierymind[/eluser]
In my project, I'm doing my best to shorten URLS without editing .htaccess file. so I used _remap function as main function in the controller to skip the function part in URLs so http://localhost/project/index.php/controller/variable1 will run similar to http://localhost/project/index.php/contr.../variable1 and this work just fine ... but what if I want to pass more variables? like: http://localhost/project/index.php/contr.../variable2 in that case, you always get "Missing argument" warnning even if you put default values like: Code: function _remap(variable1='something',variable2='something else') Is there any way to force _remap take more than 1 arguments?
[eluser]Fierymind[/eluser]
can anyone confirm or deny the fact that _remap function can take only 1 argument?
[eluser]OwanH[/eluser]
[quote author="Fierymind" date="1184127308"]can anyone confirm or deny the fact that _remap function can take only 1 argument?[/quote] CI's _remap function only accepts one argument, that being the first segment in the URL after the controller name, usually the function name in a non-_remaped URL. However you can get the remaining segments in the URL by using the URI class. I've included an example controller class to help clarify. Here it is: Code: <?php I ran some tests of this controller and here's the output I got: 1. With a URL of http://localhost/ci_playground/test/ I got the following output: Code: Class Test initialised 2. With a URL of http://localhost/ci_playground/test/mega/ I got the following output: Code: Class Test initialised 3. With a URL of http://localhost/ci_playground/test/mega/trans/ I got the following output: Code: Class Test initialised 4. With a URL of http://localhost/ci_playground/test/mega/trans/formers I got the following output: Code: Class Test initialised So the key functions here are: Code: $this->uri->total_segments()
|
Welcome Guest, Not a member yet? Register Sign In |