Welcome Guest, Not a member yet? Register   Sign In
Please consider querystring support in 2.x
#11

[eluser]moodh[/eluser]
Search can be done with some cool javascripting to create urls like this:
http://www.hamsterpaj.net/search/#foo~en...ers~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

[eluser]danmontgomery[/eluser]
~ is less ugly than &?
#13

[eluser]Phil Sturgeon[/eluser]
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.

Code:
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

[eluser]pbreit[/eluser]
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

[eluser]Phil Sturgeon[/eluser]
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.
#16

[eluser]Crimp[/eluser]
Why segments are better?

People can't/don't t read URLs and GET is largely to blame.

This "fact" was discovered when a popular blog post on the topic of Facebook login reached #1 on Google.

Angry comments soon filtered in about people not being able to log in and why did Facebook change the site and how the old one was much better.

Turned out many had no idea what the mumbo jumb in the location bar was and had developed a habit of totally ignoring it. To log in to Facebook, they went via "Facebook login" on Google and got accustomed to clicking the top result.

Segments open up URLs to become more readable, comprehensible and usable.
#17

[eluser]Phil Sturgeon[/eluser]
[quote author="Crimp" date="1277913451"]Why segments are better?

People can't/don't t read URLs and GET is largely to blame.

This "fact" was discovered when a popular blog post on the topic of Facebook login reached #1 on Google.

Angry comments soon filtered in about people not being able to log in and why did Facebook change the site and how the old one was much better.

Turned out many had no idea what the mumbo jumb in the location bar was and had developed a habit of totally ignoring it. To log in to Facebook, they went via "Facebook login" on Google and got accustomed to clicking the top result.

Segments open up URLs to become more readable, comprehensible and usable.[/quote]

Let's not confuse the conversation here by starting a "Query string v Segment URI" argument as that is irrelevant.

CI is designed to work with segments, great. We just need a way to easily throw in some ?foo=bar for Twitter, oAuth support, Facebook Connect, etc without recoding our apps or hacking it with hooks like mentioned above.

Let's put our heads together and come up with a solution. "Go team!"
#18

[eluser]WanWizard[/eluser]
There are several design decisions made that influence this (in 1.7.2):

The Input library assumes that 'enable_query_strings' == 'allow_get_array', which is not the case. The first one is your config 'switch' to decide if you want to use URI segments or the query string to define the controller/method load, the second one whether or not to erase the $_GET array. This two functions need to be split (and a config value needs to be defined for the latter).

The URI library (protocol == 'AUTO') assumes that if the $_GET array has values, they should be used for determining the URI string. Which is not the case, the 'enable_query_string' should be used to determine that. This has been correctly implemented in the Router class (_set_routing).

Structural solution for CI v1.7.2:
- add a new config variable 'allow_get_array' (boolean, default FALSE)
- in ./system/codeigniter/Codeigniter.php, move loading the Input class up, between the Config and the URI class
- in the Input library, create a new class variable 'enable_query_strings', and assign the config value to it
- in the Input library constructor, load and store the 'allow_get_array' value separate from the 'enable_query_strings' value
- in the URI library, only use $_GET if 'enable_query_strings' is TRUE

Diff for these changes in attachment.

I'll have a peek at 2.0 as well...
#19

[eluser]WanWizard[/eluser]
Checked the 2.0 code, looks like the same modifications will fix it there as well.

edit: Just did a test install of 2.0, and made the modifications. I can confirm the patch works for 2.0 as well.

I can confirm that a URL like http://test.mydomain.local/index.php/wel...ex?foo=bar adds 'welcome', 'index' to the URI segments array, and 'foo' => 'bar' to $_GET.
#20

[eluser]WanWizard[/eluser]
[quote author="Phil Sturgeon" date="1277908578"]This is still in 2.0 along with the extra screwyness that is example.com/?/controller when you use anchor() or site_url().[/quote]
Could you explain what this is about, so I can test if my patch doesn't destroy current functionality?




Theme © iAndrew 2016 - Forum software by © MyBB