CodeIgniter Forums
uri segments order - 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: uri segments order (/showthread.php?tid=14349)



uri segments order - El Forum - 12-30-2008

[eluser]al404[/eluser]
i'm just beginning with CI and i was wondering how to pass my war on URL

for example some url can miss some parameters

lets say that i have a basic url like this:
http://example.com/newsshow.php?orderby=data&limit=10

http://example.com/news/show/data/10

whatappens if i don't need on some link orderby parameter?

http://example.com/news/show//10
i wouldn't like something like this


uri segments order - El Forum - 12-30-2008

[eluser]xwero[/eluser]
You could detect the parameter by the type
Code:
if(is_numeric($this->uri->segment(3)))
{
   $limit = $this->uri->segment(3);
}
else
{
   $orderby = $this->uri->segment(3);
}
Another way to go is to add the key in front of the value like a query string and use the $this->uri->uri_to_assoc(n) method.