[Catalyst] Request

Octavian Râsnita orasnita at gmail.com
Tue Oct 27 21:16:52 GMT 2009


From: "Larry Leszczynski" <larryl at emailplus.org>
> Hi Octavian -
>
>> Is there a Catalyst Request method for getting the path and the
>> query_string? (Everything's after the base).
>>
>> I want to use it in a TT template for changing the current language.
>>
>> The current URI is something like:
>> http://www.site.com/prg?var1=val1&var2=val2
>>
>> The base for this URI is:
>> http://www.site.com/en/
>> (Because I overwritten prepare_path as in the example given on the Cat
>> wiki)
>>
>> and the URL that should be printed with the new language is:
>> http://www.site.com/ro/prg?var1=val1&var2=val2
>
> Not sure if this gets you all the way there, but you could call
> "c.req.uri" with no arguments, that should give you the current request
> including base, path and query string.  Then you could strip off
> c.req.base from the beginning of that string.

Thank you Larry, but the problem is that the base was overwritten and it 
contains some more than the uri, so I can't cut it from the URI.

Thank you Evan. Your solution was helpful.
I didn't know that c.req.uri is not just a string, but an object that has 
its own methods, and c.req.uri.path_query was the one I needed.

Octavian




More information about the Catalyst mailing list