How display checked filter variable value in url - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How display checked filter variable value in url (/showthread.php?tid=74914) |
How display checked filter variable value in url - gruhol - 11-25-2019 I am a basic user of code igniter and PHP.I have some products page with filters. How to created a URL link like this: Code: http://somepage.pl/products?color=red I know I can do above url when I will change the config line:
Code: $config['enable_query_strings'] = FALSE; on TRUE. But I want to use this option only one controller and one function. I can write same code whitch it will filter this products by color for example, but I want create link like on top. People will be able to share this link. RE: How display checked filter variable value in url - Wouter60 - 11-25-2019 Simply use $this->input->get('color') in your controller to fetch the variable that was passed in the query string. You don't need to change the setting of $config['enable_query_strings'). If you would set to true, CI will no longer accept url's with segments, but it wants the controller and method as query string variables too. E.g.: PHP Code: http://somepage.nl/?c=products&m=index&color=red With $config['enable_query_strings') set to false, your url will do just fine. Remember to process the get variables in the index method of the controller, because CI expects a controller and a method in the url. If you omit the method, CI points to the index method in the given controller. RE: How display checked filter variable value in url - gruhol - 11-25-2019 Thanks for this. I thought get var was disable in codeigniter. |