Using ? to pass additional parameters

Chad
Your instructions were very good and things overall work. But I've run into a problem. I sometimes need to pass additional parameters to the pages and can't use POST. So I end up with a url like http://www.domain.com/admin/articles?page=2

And I don't end up with a variable called 'page' with a value of '2'. Instead it looks like I end up with a variable of '/admin/articles?page' with a value of '2'.

Any ideas? I'm guessing it has to do with the rewrite rules.

Thanks!

RE: Using ? to pass additional parameters

Rich
6-8-2006 17:35
To get additional parameters (such as .../admin/articles?page=2) to work, I did the following:

In ActionPack/lib/ActionController/cgi_process.rb

In Module ActionController, I replaced:

def query_string
if (qs = @cgi.query_string) && !qs.empty?
qs
elsif uri = @env['REQUEST_URI']
parts = uri.split('?')
parts.shift
parts.join('?')
else
@env['QUERY_STRING'] || ''
end
end

with...

def query_string
if (qs = @cgi.query_string) && !qs.empty?
#rbw qs
parts = qs.split('?') #rbw - add
parts.shift #rbw - add
parts.join('?') #rbw - add
elsif uri = @env['REQUEST_URI']
parts = uri.split('?')
parts.shift
parts.join('?')
else
@env['QUERY_STRING'] || ''
end
end

I'm not completely certain this code is right. In your controller or view, the params hash will now contain 'page' with a value of 2, so your controller should work as expected.

But params also still contains the /admin/articles?page variable as well. This seems harmless enough, but since I don't know how it got there, there may be other annoying side-effects that I haven't discovered.

Hope this helps.

Rich

Name:
Email:
Url:
Message:

I love umbraco. Click here to go to the umbraco developer site