ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Please consider querystring support in 2.x

June 29, 2010 3:52am

Subscribe [23]
  • #1 / Jun 29, 2010 3:52am

    pbreit

    206 posts

    I just want to register a very strong request to support querystrings by default in 2.0 or 2.x. I think most CI developers would greatly benefit from this and many more developers would be able to use CodieIgniter. Thank you.

  • #2 / Jun 29, 2010 4:55am

    Mat-Moo's avatar

    Mat-Moo

    350 posts

  • #3 / Jun 29, 2010 5:45am

    pbreit

    206 posts

    Yeah, but if you enable querystrings, you lose segments. One of the problems is that the absence of querystrings has led quite a few CI developers to consider the absence acceptable which is a big community problem. The forums are littered with possible work-arounds but it’s hard to determine if any of them are reliable. It would be best for CodeIgniter to support querystrings “out-of-the-box”. This should be a relatively non-controversial belief.

  • #4 / Jun 29, 2010 5:48am

    n0xie's avatar

    n0xie

    1381 posts

    Didn’t we already have this discussion? Querystring is enabled in CodeIgniter, if you do it right. It’s just turned off by default.

  • #5 / Jun 29, 2010 5:57am

    pbreit

    206 posts

    I am still not clear on the best way to enable. There are dozens of different suggestions on the forums. Setting enable_query_strings to TRUE is not a good answer since it disables segments (so please stop recommending this by itself; it’s a disservice to developers).

    I also think it’s a problem that CodeIgniter developers feel that it is acceptable to develop web sites without querystrings. Frameworks should help developers develop in good ways. The search function for these forums is a good example of how not to implement search.

  • #6 / Jun 29, 2010 6:23am

    mddd

    635 posts

    The ‘search’ argument keeps coming back in this discussion. But it has nothing to do with the topic. You can build a search with no problem at all, using a url like ‘www.example.com/search/my+search+keywords’. That would do exactly the same as ‘www.example.com/search?q=my+search+keywords’.

    The fact that this forum caches results using some kind of unique id to keep track of the results, has nothing to do with the question of query strings.

    Like other frameworks, CodeIgniter has a set of starting points and views, providing structure in the development process. Other frameworks have different assumptions and views.

    Saying that developing without query strings is a problem, is your point of view. I don’t use query strings and my projects work fine.

  • #7 / Jun 29, 2010 6:47am

    pbreit

    206 posts

    Fine, you picked the most basic search example. How about a search with a few parameters? Yes, search is one area where querystrings are not only widely used (universally, in fact) but correctly used.

    The other huge area are 3rd party services. Not everyone creates self-contained web sites. In fact, the great thing about the internet is integrating with other services.

    Why do you guys defend this deficiency. I don’t get it. Seriously. It’s not *my* point of view. It is the point of view of the vast majority of web developers including folks like Tim Berners Lee, Roy Fielding, Rasmus Lerdorf, et al.

  • #8 / Jun 29, 2010 6:59am

    mddd

    635 posts

    So? What’s wrong with http://www.example.com/homes/ny/400k/500k/app/p10 for a search of New York appartments between $400-500k, showing page 10 of the results? I just mean to say: there is no 1 correct way to do this. Calling a url like I wrote above is just as valid as calling a url with a query string attached.

    You might not understand why we like the way CI does it, but likewise, I don’t get your obsession with having the get variables. It is up to everyone to build a site the way THEY like.

    You are right that get variables are a totally legitimate way of using the web. But it is not a *requirement* to use them in your site.
    Seriously, if it is such a big deal to you, just use a framework that better suits your needs.

    And, finally, like has been said many times: CI DOES support them if you want them.

  • #9 / Jun 29, 2010 7:07am

    cahva's avatar

    cahva

    662 posts

    I dont know whats the fuss about. Enabling query strings does NOT mean that you lose segments. Thats bullcrap as Dr.Phil would say. So they can co-exist and you get the goodies from both worlds. For example I have couple of ecommercesites where I need query strings because most payment gateways return stuff using that. There is no problem whatsoever to use it. For example one of gateways it will return to my shop like this:

    http://www.mydomain.com/checkout/success/gateway_name?ORDER_ID=1234&TIMESTAMP=12345678&PAID=1&METHOD=123

    So there you have perfect example of having segments (controller Checkout with method success with parameter gateway_name) and querystring which I can access using $this->input->get(‘ORDER_ID’) etc.

    I too think that it could easily be enabled by default because theres no harm in that. But its just a config setting(s) that can be enabled when needed(and 95% of the time its not needed).

    Oh yeah, this atleast works with apache(mod_php) and config settings set to this:

    $config['uri_protocol']    = "PATH_INFO";
    $config['enable_query_strings'] = TRUE;
  • #10 / Jun 29, 2010 10:46am

    n0xie's avatar

    n0xie

    1381 posts

    If changing the uri protocol is too ‘restricting’ for you : http://github.com/dhorrigan/codeigniter-query-string

  • #11 / Jun 29, 2010 11:09am

    moodh

    94 posts

    Search can be done with some cool javascripting to create urls like this:
    http://www.hamsterpaj.net/search/#foo~entertain~sex_sense~users~groups it least to a swedish site but you could try it out =)
    It’s easy once you start thinking outside the box, querystrings is UGLY, they’re shit as far as SEO goes and seriously, & and ? in urls? no thanks!

  • #12 / Jun 29, 2010 11:41am

    danmontgomery's avatar

    danmontgomery

    1802 posts

    ~ is less ugly than &?

  • #13 / Jun 29, 2010 12:26pm

    Phil Sturgeon's avatar

    Phil Sturgeon

    2889 posts

    Actually this situation get’s a little more complicated in CodeIgniter 2.0 as I found that if I had $config[‘enable_query_strings’] = TRUE; then the site_url() would start to build me some pretty funky URL’s.

    function site_url($uri = '')
        {
            if ($uri == '')
            {
                if ($this->item('base_url') == '')
                {
                    return $this->item('index_page');
                }
                else
                {
                    return $this->slash_item('base_url').$this->item('index_page');
                }
            }
    
            if ($this->item('enable_query_strings') == FALSE)
            {
                if (is_array($uri))
                {
                    $uri = implode('/', $uri);
                }
        
                $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
                return $this->slash_item('base_url').$this->slash_item('index_page').trim($uri, '/').$suffix; 
            }
            else
            {
                if (is_array($uri))
                {
                    $i = 0;
                    $str = '';
                    foreach ($uri as $key => $val)
                    {
                        $prefix = ($i == 0) ? '' : '&';
                        $str .= $prefix.$key.'='.$val;
                        $i++;
                    }
    
                    $uri = $str;
                }
    
                if ($this->item('base_url') == '')
                {
                    return $this->item('index_page').'?'.$uri;
                }
                else
                {
                    return $this->slash_item('base_url').$this->item('index_page').'?'.$uri;
                }
            }
        }

    Spot the issue there?

    The only way we have this working “nicely” in PyroCMS without the user having to faff with uri_protocol is to use hooks which is not exactly the cleanest solution.

  • #14 / Jun 29, 2010 2:45pm

    pbreit

    206 posts

    The dhorrigan hook looks promising, thanks.

    Could you all please stop pretending that querystrings are reasonably supported. Are they not supported because “that’s just the way it was designed” or are there valid reasons?

  • #15 / Jun 30, 2010 6:36am

    Phil Sturgeon's avatar

    Phil Sturgeon

    2889 posts

    I agree. They aren’t supported well at all. In 1.7.2 they can be hacked but you never could leave $config[‘uri_protocol’] = ‘AUTO’ on to support them globally thorough your application as ?foo1=bar1&foo2=bar2 would then become /foo1/foo2.

    This is still in 2.0 along with the extra screwyness that is example.com/?/controller when you use anchor() or site_url().

    While I understand this is built to support servers without mod_rewrite, CGI PHP, etc there needs to be a middle-ground. Right now I can’t think what that is, but its safe to say query string support is not nice atm, even if we can hack it.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases