CodeIgniter Forums
Using GET and trying to get function arguments set - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using GET and trying to get function arguments set (/showthread.php?tid=6775)



Using GET and trying to get function arguments set - El Forum - 03-11-2008

[eluser]kaosweaver[/eluser]
This page:
http://ellislab.com/codeigniter/user-guide/general/urls.html

tells me how to setup the CI so I can use the keywords c and m to pull the controller and function, however, when I set the third parameter to the function's argument name (statename in my case), the function ignores this. The example in the docs has:

Code:
index.php?c=products&m=view&id=345

So, I'm assuming there is a way to use the id=345 part, it would be logical if that was the function's argument, meaning, I would expect the products controller to have a function that starts with:

Code:
function view($id) {
...
}

And the id from the URL string would be put in the $id of the view. In our case, this isn't happening, so, how do we make this happen?


Using GET and trying to get function arguments set - El Forum - 03-11-2008

[eluser]Seppo[/eluser]
The extra get arguments are not passed to the function... you can recover them by the superglobal $_GET array or throught $this->input->get('id')


Using GET and trying to get function arguments set - El Forum - 03-11-2008

[eluser]kaosweaver[/eluser]
Wow - that is going to be a pain - we have a lot of controllers and we need to be able to catch google/MSN/Yahoo URL string passed keyword searches and we also need the landing pages to be able to be state specific (the joys of SEO and pay per click tracking)

Thanks for the info, may have to crack open the application code and make it work easier for us.


Using GET and trying to get function arguments set - El Forum - 03-11-2008

[eluser]Seppo[/eluser]
The main issue is that you shouldn't be able to know the function parameters name.. so you won't knwo if the first argument should be $_GET['id'] or something else...
May be if you are using PHP 5 you can use reflection


Using GET and trying to get function arguments set - El Forum - 03-11-2008

[eluser]Pygon[/eluser]
make sure "enable_query_strings" is set to TRUE in the config.