Part of the EllisLab Network
   
2 of 3
2
CI Stupidly Kills GET Data
Posted: 07 January 2007 10:38 PM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  9
Joined  10-16-2006

Derek,

Code Igniter works with either URI Segments OR Query Strings.. not both.

If you enable query strings, then the URI segments stuff is disabled.  So you can’t use segments or the any URL helper.

You would then have to use query string vars for the entire app! e.g.

http://localhost/index.php?c=controller&m=method

-

This thread is talking about using both segments and query strings together. e.g.

http://localhost/index.php/controller/method?query=data

This, as alan.briolat said, can be done using $_REQUEST[] array (as CI doesn’t unset this like it does the $_GET array).

-

Frameworks like Code Igniter are supposed to help us code faster and better.. Not put obstacles in our way and force us to waste time getting around them.

Profile
 
 
Posted: 07 January 2007 10:59 PM   [ Ignore ]   [ # 17 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6712
Joined  03-23-2006

You’re right.  My last post wasn’t in response to the opening question, it was a response the post above mine.  I understand the desired goal here, and to that end I think that Shadowhand’s solution is the path I’d follow.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 08 January 2007 02:14 AM   [ Ignore ]   [ # 18 ]  
Grad Student
Avatar
Rank
Total Posts:  76
Joined  12-17-2006
Derek Allard - 07 January 2007 10:59 PM

You’re right.  My last post wasn’t in response to the opening question, it was a response the post above mine.  I understand the desired goal here, and to that end I think that Shadowhand’s solution is the path I’d follow.

Derek,

So what problems/implications do you see whith enabling GET to work properly? And what are the reasons anyway to handle GET this way? I really would like to discuss this further here. I still don’t GET (;-)) it.

Thank you very much in advance!

greets Rico

Profile
 
 
Posted: 08 January 2007 05:34 AM   [ Ignore ]   [ # 19 ]  
Grad Student
Avatar
Rank
Total Posts:  76
Joined  12-17-2006

and by the way ...thats still no proper answer to Kristians problem ...
he obviously just wants to make a controller which is being able to search WITHOUT the hassle of turning query strings on for the entire site or to have to cope with allowed uri chars

greets Rico

Profile
 
 
Posted: 08 January 2007 05:55 AM   [ Ignore ]   [ # 20 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  207
Joined  12-22-2006

Why does CI actually unset the $_GET parameters? I dont think it would break anything if they wouldnt be unset?

That way:

http://myurl.com/controller/method?var1=blaat

Would work afaik?

If not then perhaps CI should fill the $_GET array with in this case only:

$_GET['var1'] = 'blaat';

I havent looked at the code that parses the query_string, but to me it would solve alot if the $_GET array wasnt unset.

Profile
 
 
Posted: 17 January 2007 10:33 AM   [ Ignore ]   [ # 21 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  187
Joined  06-25-2006

Perhaps you’d be interested in my solution:
http://codeigniter.com/forums/viewthread/47107/

It also solves the annoying bug with input handling when “magic quotes” are enabled.

 Signature 

Join us in #codeigniter on irc.freenode.net

Profile
 
 
Posted: 18 January 2007 03:58 AM   [ Ignore ]   [ # 22 ]  
Lab Assistant
RankRank
Total Posts:  109
Joined  05-25-2006

@champs: I have got errors using your classes. The patch from nvidiafx works for me.
http://www.codeigniter.com/forums/viewthread/2659

 Signature 

CI 1.5 on WAMP (W2k Pro, Apache 2, MySQL 4.1, PHP 4.4)

Profile
 
 
Posted: 18 January 2007 12:13 PM   [ Ignore ]   [ # 23 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  187
Joined  06-25-2006

@Jozef:
I’m not a fan of patches.  Could you possibly post some details of your issue in my extension’s original thread?

 Signature 

Join us in #codeigniter on irc.freenode.net

Profile
 
 
Posted: 20 January 2007 04:46 AM   [ Ignore ]   [ # 24 ]  
Summer Student
Total Posts:  10
Joined  01-16-2007

Yeah, this doesn’t make sense to me either. It’s the first time I’ve encountered such a concept, but there isn’t a real explanation offered for why it has to be this way (does it break something?). There’s the patch, but it’d be nice if the framework was updated - either straight out allow $this->input->get(), or at the very least make it a preference to switch on/off (even if it was off by default).

Profile
 
 
Posted: 26 January 2007 10:05 PM   [ Ignore ]   [ # 25 ]  
Summer Student
Avatar
Total Posts:  6
Joined  01-02-2007

The use of URL ‘GET’ method is a whole lot better and SEO compatible. The cool thing is that Google will archive both function/mode1 & function/model2 but they will not archive ANYTHING IN your site if you use GET. So unless you want the only page in your entire site to be archived the first page query strings are a bad idea. They kill any possibility of good SEO.

1. Not true - Google for “RJ-0460-0” if you don’t believe me smile On one of our sites - dogandlemon.com - we have a huge number of indexed GET queries in Google, and it’s one of our major inroads. Google has no issue with this, and neither do we!

2. That said, I don’t think that Google compatibility should dictate our behaviour. They didn’t write the HTTP spec, and there are valid reasons for _GET requests. If this functionality isn’t to be re-enabled in CI (I can respect the architectural decision, though I’d respect it a lot more if it was explained WHY we are obliged to choose between nice URLs and _GET - normally I combine the two for cacheable, dynamic pages.

Human-readable form queries to me are (for many users) about being able to edit the value pairs, rather than having to decode URI structures that offer no clue as to what the third segment relates to - start date? finish date? LIMIT? OFFSET? ...

CI rocks, but I feel that unsetting $_GET without a good reason is unreasonable. It’s too useful, and I don’t see how it conflicts with nice URIs (I’d really appreciate if someone can explain why this is).

Profile
 
 
Posted: 27 January 2007 04:31 AM   [ Ignore ]   [ # 26 ]  
Grad Student
Avatar
Rank
Total Posts:  95
Joined  09-17-2006

Actually heres what Google says

If you decide to use dynamic pages (i.e., the URL contains a “?” character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few.

Google SEO TIPS

I am still undecided on the issue but I would like to be able to use get at times…

 Signature 

Code Igniter for Designers

Profile
 
 
Posted: 27 January 2007 09:08 AM   [ Ignore ]   [ # 27 ]  
Summer Student
Total Posts:  10
Joined  01-16-2007

Google properly indexes forums all the time, most of which use query strings still. Notice that Google uses them for their own search engine.

Regardless, SEO isn’t a reason to completely disable a valid - and useful - standard for everyone, and I sincerely doubt that is what the CI creators had in mind.

Profile
 
 
Posted: 19 March 2007 12:00 PM   [ Ignore ]   [ # 28 ]  
Grad Student
Rank
Total Posts:  35
Joined  02-25-2007

I’m a new CI user and I just wanted to agree that I have seen no good reason for deleting the get array - PHP provides a PATH_INFO variable and the GET array and both are useful. 

but one question - why can those us us that want $_GET just change the _sanitize_globals function in input.php to not delete the $_GET array - anyone tried that?  I know it’s changing a core file - but it’s simple change, no?  I haven’t had the need yet so I haven’t tried.

Yehosef

Profile
 
 
Posted: 27 March 2007 03:28 PM   [ Ignore ]   [ # 29 ]  
Summer Student
Total Posts:  30
Joined  03-26-2007

To Enable URI Segments AND Query Strings

If you want to enable the behavior you want, it’s really just a few simple changes in your config.php

$config['uri_protocol'] = "PATH_INFO";


This removes the query string from the URI so normal uri/routing/style works fine.

$config['enable_query_strings'] = TRUE;


This doesn’t remove the $_GET superglobal.

$config['permitted_uri_chars'] = '';


This allows query-string characters.  You could alternately modify the permitted to allow ?, &, ; and =, I just allow all for ease of use.

Unless you send a query variable that matches what you define as $config[‘controller_trigger’] the normal URI routing is handled.


Doing this I can access pages like:  www.domain.com/controller/function/parameter1/parameter2?getkey=getvalue

And it works just fine.

Profile
 
 
Posted: 22 October 2007 04:07 AM   [ Ignore ]   [ # 30 ]  
Summer Student
Total Posts:  10
Joined  10-11-2007
ZareMedia - 27 March 2007 03:28 PM

To Enable URI Segments AND Query Strings

If you want to enable the behavior you want, it’s really just a few simple changes in your config.php

$config['uri_protocol'] = "PATH_INFO";


This removes the query string from the URI so normal uri/routing/style works fine.

$config['enable_query_strings'] = TRUE;


This doesn’t remove the $_GET superglobal.

$config['permitted_uri_chars'] = '';


This allows query-string characters.  You could alternately modify the permitted to allow ?, &, ; and =, I just allow all for ease of use.

Unless you send a query variable that matches what you define as $config[‘controller_trigger’] the normal URI routing is handled.


Doing this I can access pages like:  www.domain.com/controller/function/parameter1/parameter2?getkey=getvalue

And it works just fine.

Has anyone managed to get this to work. I really need to use mixed GET/segment urls. My rewrite rules are:

  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ /index.php?$1 [L]

I changed the config settings as specified above, but now if I try to go to http://mydomain.com/mycontroller/mymethod/?foo=bar, it tries to route me to the default controller. If I remove the rewrite rules and go to http://mydomain.com/index.php/mycontroller/mymethod/?foo=bar, the same thing happens.

Does anyone have the secret to getting this working? Thanks.

~rvr

Profile
 
 
   
2 of 3
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64457 Total Logged-in Users: 14
Total Topics: 80968 Total Anonymous Users: 0
Total Replies: 435701 Total Guests: 184
Total Posts: 516669    
Members ( View Memberlist )