![]() |
$this->input->get() - what to link to?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: $this->input->get() - what to link to?? (/showthread.php?tid=35126) |
$this->input->get() - what to link to?? - El Forum - 10-19-2010 [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? $this->input->get() - what to link to?? - El Forum - 10-19-2010 [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 { $this->input->get() - what to link to?? - El Forum - 10-19-2010 [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??) $this->input->get() - what to link to?? - El Forum - 10-20-2010 [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 { $this->input->get() - what to link to?? - El Forum - 10-20-2010 [eluser]cahva[/eluser] You dont have to use isset() on $this->input->get('something'). It will return FALSE if its not set. $this->input->get() - what to link to?? - El Forum - 10-20-2010 [eluser]Vladimir Aleksiev[/eluser] My mistake! (: $this->input->get() - what to link to?? - El Forum - 10-20-2010 [eluser]umbongo[/eluser] OK so i have the following in a function; Code: $var = $this->input->get('url_var'):'5'; $this->input->get() - what to link to?? - El Forum - 10-20-2010 [eluser]WanWizard[/eluser] I would give you one too... What are you trying to do here? What does the :'5' do there? $this->input->get() - what to link to?? - El Forum - 10-20-2010 [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. $this->input->get() - what to link to?? - El Forum - 10-20-2010 [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'; |