![]() |
mixed URL's - 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: mixed URL's (/showthread.php?tid=11589) Pages:
1
2
|
mixed URL's - El Forum - 09-15-2008 [eluser]Unknown[/eluser] Hi all! I am searching the right way... =) How can I use this url, for example, http://example.com/controller/method/?par1=val1&par2=val2 ... etc I like CI scheme /controller/method/arguments_1/arguments_2 But best way (sometimes) is use mixed url... is it possible with CI help ?? sorry for my ugly English ( mixed URL's - El Forum - 09-15-2008 [eluser]xwero[/eluser] You can set the url_protocol to INFO_PATH and set the enable_query_strings to TRUE to use query strings. The problem with this method is that it isn't pagerank friendly because then your pages are reachable with controller/method and ?c=controller&m=method. So you have to find something to make urls that don't need GET unreachable. mixed URL's - El Forum - 09-15-2008 [eluser]tomcode[/eluser] You can use http://example.com/controller/method/val1/val2/val3 and fetch with Code: $segments = $this->uri->segment_array() See details and more methods in the User Guide mixed URL's - El Forum - 09-15-2008 [eluser]Sumon[/eluser] another way to get url value is: Code: class controller_name Code: function method($var1='',$var2='',$var3='') mixed URL's - El Forum - 09-16-2008 [eluser]Crafter[/eluser] xwero, tomcode and Sumon are all spot on. But understand that your usage http://example.com/controller/method/?par1=val1&par2=val2 is incorrect. The reason for this is that Code Igniter works with "smart urls" by rewriting the index,php file. So you should be using http://example.com/index.php?c=controller&m=method&par1=val1&par2=val2 In addition, CI overwrites and hides _GET, so you can't easily reach the URL agruments. If you want to use flexible options use a scheme like this, or similar, http://example.com/controller/method/par1=val1,par2=val2 but then you'll have to separate the arguments yourself, and configure CI so that it allows the special characters you use. Let us know how it goes. mixed URL's - El Forum - 09-16-2008 [eluser]Unknown[/eluser] [quote author="Crafter" date="1221567070"] If you want to use flexible options use a scheme like this, or similar, http://example.com/controller/method/par1=val1,par2=val2 but then you'll have to separate the arguments yourself, and configure CI so that it allows the special characters you use. Let us know how it goes.[/quote] cool idea! I'll will try! mixed URL's - El Forum - 09-16-2008 [eluser]Bramme[/eluser] what about example.com/controller/method/var1/var2/?path=path/to/file.txt How should you handle that? mixed URL's - El Forum - 09-16-2008 [eluser]xwero[/eluser] The problem with tomecodes solution is that none of the segments are optional, if you want them to be you need to do a lot of checking. Crafter why are mixed urls incorrect? google uses http://www.google.be/search?q=... . If you translate that to CI search is the controller and the method is index. The query string are the parameters. You don't even have to add a custom route to make this work. Why should you waste additional code for splitting segments if you can separate the PATH_INFO part from the query strings? This is what adding parameters as segments and your solution does. If you follow the instructions in my first reply the GET global will not be cleared and you can use it as you where used to in 'plain' php. It's not because CI prefers it one way you should follow it blindly. mixed URL's - El Forum - 09-16-2008 [eluser]Bramme[/eluser] So xwero, for my problem, I should follow your advice as in the first reply? mixed URL's - El Forum - 09-16-2008 [eluser]xwero[/eluser] Bramme i think you are doing something tricky. You shouldn't show your file structure in your url. Can't you get the file path based on the parameter segments in the url? |