$this->input->get() - what to link to?? |
[eluser]umbongo[/eluser]
I am trying to figure out how to use the get in CI. with regular PHP i would have linked to something like page.php?some_data=value1&some_other_data=valueA what do i do in CI as there is no *.php in the URL?
[eluser]cahva[/eluser]
If your server is running php as a module in apache, set these in config.php Code: $config['uri_protocol'] = "PATH_INFO"; ..thats it! Now you can use for example $this->input->get('some_data') for example: url: yoursite.com/foo?some_data=value1&some_other_data=valueA Code: Class Foo extends Controller {
[eluser]umbongo[/eluser]
Thanks, awesome! So i have some variables being set this way, how do i set a default value for them when there is no input from get?? (Also, i don't really understand how you would use your code?? in the example index would print 'value1 valueA'?? Is this just to show that it worked??)
[eluser]Vladimir Aleksiev[/eluser]
[quote author="umbongo" date="1287558723"]Is this just to show that it worked??[/quote] Yes! You can set your default values like this: Code: Class Foo extends Controller { In my opinion the best way to send parameters to a controller function is to do it codeigniter style, like this. http://site.com/foo/index/param1/param2 Code: Class Foo extends Controller {
[eluser]cahva[/eluser]
You dont have to use isset() on $this->input->get('something'). It will return FALSE if its not set.
[eluser]umbongo[/eluser]
OK so i have the following in a function; Code: $var = $this->input->get('url_var'):'5';
[eluser]WanWizard[/eluser]
I would give you one too... What are you trying to do here? What does the :'5' do there?
[eluser]umbongo[/eluser]
well.. i am trying to set the default value where there is nothing to 'get'.. so i was trying to set this to '5' in this example.
[eluser]Vladimir Aleksiev[/eluser]
[quote author="umbongo" date="1287610035"]OK so i have the following in a function; Code: $var = $this->input->get('url_var'):'5'; This is what you need. (: Code: $var = ($this->input->get('url_var'))?$this->input->get('url_var'):'5'; |
Welcome Guest, Not a member yet? Register Sign In |