Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] How to use URI Segments and Query Strings in the same project
#1

[eluser]fensen[/eluser]
CodeIgniter is SO powerful!

If you want to use URI Segments and Query Strings in the same project, go to
Code:
APP/config/config.php
and change:
Code:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;

This will allow you to use URI Segments, URI Segments parameters and Query String parameters!
e.g.
Code:
/controller/method/param1/param2/?param3=xxx&param4=yyy

This has just saved my life!!!
#2

[eluser]Phil Sturgeon[/eluser]
Nicely done, had been wondering how to mix them for a while now. This has been tested and works nicely! :-)
#3

[eluser]amrnt[/eluser]
[quote author="fabian_o" date="1229074725"]CodeIgniter is SO powerful!

If you want to use URI Segments and Query Strings in the same project, go to
Code:
APP/config/config.php
and change:
Code:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;

This will allow you to use URI Segments, URI Segments parameters and Query String parameters!
e.g.
Code:
/controller/method/param1/param2/?param3=xxx&param4=yyy

This has just saved my life!!![/quote]

HOW it saves your life... it doesn't work with me ~~~!!!

when i write
www.xppx.com/controller/function/
it returns me to the root page without changes in the URL
moreover when i supply params to become
www.xppx.com/WHATEVER_TEXT_OR_WITHOUT/?c=controller$m=function it works fine....
#4

[eluser]Bahodir[/eluser]
maybe you should write something like this: www.xppx.com/index.php/controller/function/
#5

[eluser]lifo101[/eluser]
(sorry for waking an old thread)

Does anyone know of any OS specific side effects by using PATH_INFO like this? (eg: IIS on Windows)
#6

[eluser]PHP Creative[/eluser]
Sorry for bumping this thread. Sad

With this setup, I need to use the index.php in the URL. Is there anyway to get around this?

Thanks a million
#7

[eluser]Zorancho[/eluser]
I am using .htaccess to remove the index.php from the url. By using this approach about query strings i am able to do this:
http://www.example.com/products/edit/2?category=32

Then i can get the 2 which is the id of the product like this in my controller:
Code:
function edit($id = 0)
{
    echo $id; //prints 2
    echo $_GET['category']; //32
}

Is there anything wrong with this?
#8

[eluser]rebellion[/eluser]
This doesn't work with me neither.

I'm using an SMS service that sends get variables to an URL, in my case: http://mydomain.com/sms/receive_sms/

But CodeIgniter can't read http://mydomain.com/sms/receive_sms/?msgid=x&number=x etc.

What to do? :/
#9

[eluser]mindprojects[/eluser]
Fully working! Perfect...this morning i was struggling with this as well....
The only problem will be with the pagination.....on how to get the right uri segment.
#10

[eluser]mindprojects[/eluser]
For the pagination we'll need to create a custom pagination to append the query string everytime at the end of the url string
so that the URI SEGMENT will be at the same place everytime.We we'll have to build something like:
eg:
controller/function/offset?QUERY_STRING




Theme © iAndrew 2016 - Forum software by © MyBB