Welcome Guest, Not a member yet? Register   Sign In
Mixing URI and GET
#1

[eluser]joao.sobrinho[/eluser]
Hi.

I'm trying to use URI along with GET links.

The problem is that when I use and GET variable, CodeIgniter doesn't recognize any URI segment.

I want to use something like this: www.your-site.com/who/what/where/?id=23&cat=231

But CI makes me to have to use www.your-site.com/?c=controler1&m=themethod&id=23&cat=231


I need it because I already have a huge number of methods implemented with the URI segments, but some new requirements came out, and I want to pass some other variables that are independent from the number of variables that I am already using in the links. If there is another way of doing this I also accept suggestions. Smile

How can I solve this ? Is it possible to use both URI and GET in the same link ?


Thanks for your attention.
#2

[eluser]Phil Sturgeon[/eluser]
Code:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
#3

[eluser]joao.sobrinho[/eluser]
Thanks.
#4

[eluser]physicsdave[/eluser]
[quote author="Phil Sturgeon" date="1265410082"]
Code:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
[/quote]

You could optionally enable GET params in just the controllers you want them by doing something like this.

in config:
Code:
$config['uri_protocol'] = "PATH_INFO";

in controller:
Code:
parse_str($_SERVER['QUERY_STRING'], $get);

In that example the '$get' var would contain all info.

Enjoy,
#5

[eluser]mabsi[/eluser]
Hello everyone! I'm new here. I just registered because of this GET parameters problem that I have. I have tried the usual solutions suggested on the forum but with no luck.

PATH_INFO is not available on the shared host I'm using. I have also tried every other option for uri_protocol. Enabling query_strings did not work either (used with segment based URLs).

On my development machine I got it working using the following .htaccess and setting uri_protocol to QUERY_STRING:
http://codeigniter.com/wiki/mod_rewrite/

But on my production machine (shared host) the same doesn't quite work. It works otherwise but when I give it a URL which ends like ?a=� (a is percent E4) it says it doesn't find the page. But e.g. ?a=a is fine. I don't get it? That doesn't make any sense to me. The characters are allowed so it's not that.

Which brings me to the other problem: my workaround with POST doesn't work either because I want to have a semantically somewhat meaningful URLs which can be bookmarked. I used urlencode and redirect but then CI complained of unallowed characters. There was no unallowed chars because urlencoding (consider the previous example). I could get it to work if I allowed 'ä' (percent E4) but that's no option. In this case I can't explicitly allow every character for every language which I do not even know.

I just don't understand how a basic thing like getting a simple URL to work can be so difficult. GET is obviously discouraged in CI even though there are clear cases when to use it:
http://www.w3.org/2001/tag/doc/whenToUse...#checklist

I'm sorry if I seem to be very negative. I haven't written or spoken English in years and I'm also running out of sensible options and worse: time. I've spent over 12 hours just to get a simple web link to work. It feels so stupid. I feel so stupid. I'm no pro with PHP or Apache but the task isn't supposed to be very hard either... I hope someone can help me, please?
#6

[eluser]fuksito[/eluser]
I have a problem like <b>mabsi</b>, any URL that contains only one param does not work, like

example.com/product/?id_cat=15
It will say "Page not found"

But if i write
example.com/product/?1=1&id_cat=15
It will work as supposed to

I`m tired to add ?1=1 to all get links, what is the problem?
#7

[eluser]2think[/eluser]
I'm not very familiar with enabling GET in Codeigniter but throwing a suggestion out there, have you all checked into the URI Routing section of the User Guide? http://ellislab.com/codeigniter/user-gui...uting.html

It uses regular expressions so not sure if that helps any or not at all (after enabling GET in your config.php as Phil suggests of course).
#8

[eluser]mabsi[/eluser]
I give up. I'll build the URLs using only segmented structure making them less human readable using some other encoding method than urlencode() because of my urlencode vs. allowed chars problem.
#9

[eluser]pbreit[/eluser]
I've had luck with the approach provided above with just one param:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;




Theme © iAndrew 2016 - Forum software by © MyBB