Access to params within extension


#1

Can someone give me a leg up? I’m finding it difficult to find the
request.params array anywhere within the Page context. I have setup a
custom route as part of my extension (not for the admin area, but for
the main site) and in that route I have mapped some custom params I
really want to access.

Any ideas… I tried tag.local.parms[], tag.page.param[],
@request.param[], etc.

Looking through the models/page.rb and taggable I don’t see any place
I’d get this from, but I’m hoping I’m missing something.

Thanks,

Loren J.
removed_email_address@domain.invalid


#2

If you’ve made a custom route, then that route will be handled by a
regular rails controller, not a page object.


From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Loren J.
Sent: Monday, 22 January 2007 5:33 PM
To: removed_email_address@domain.invalid
Subject: [Radiant] Access to params within extension

Can someone give me a leg up? I’m finding it difficult to find
the request.params array anywhere within the Page context. I have setup
a custom route as part of my extension (not for the admin area, but for
the main site) and in that route I have mapped some custom params I
really want to access.

Any ideas… I tried tag.local.parms[], tag.page.param[],
@request.param[], etc.

Looking through the models/page.rb and taggable I don’t see any
place I’d get this from, but I’m hoping I’m missing something.

Thanks,

Loren J.
removed_email_address@domain.invalid


#3

No, I get that. Here is my custom route:

map.connect ‘event-
calendars/:calendar_group/:calendar/:period’, :controller =>
‘site’, :action => ‘show_page’, :url => ‘calendar’

So I’m forward the control back to the Radiant Site controller.

My question is within the Page type which I attach to the real
Radiant page found at “/calendar” how can I cleanly access the url
params ? This is how I solved it for now, but it’s ugly and inflexible:

class EventCalendar < Page

tag “calendar” do |tag|
path = @request.request_uri.split("/")
p = Hash[:calendar_group => path[2], :calendar => path
[3], :period => path[4]]

end
end

Just hoping to find a better way.

Thanks,

On Jan 21, 2007, at 11:52 PM, Daniel S. wrote:

If you’ve made a custom route, then that route will be handled by a
regular rails controller, not a page object.

Loren J.
removed_email_address@domain.invalid


#4

Hmmm… seems that tags ARE instance_eval’d on the page, so ignore my
last email. You’re after params as interpreted by controllers. I think
those are available with @request.path_parameters


From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Loren J.
Sent: Monday, 22 January 2007 6:10 PM
To: removed_email_address@domain.invalid
Subject: Re: [Radiant] Access to params within extension

No, I get that. Here is my custom route:

map.connect ‘event-calendars/:calendar_group/:calendar/:period’,
:controller => ‘site’, :action => ‘show_page’, :url => ‘calendar’

So I’m forward the control back to the Radiant Site controller.

My question is within the Page type which I attach to the real
Radiant page found at “/calendar” how can I cleanly access the url
params ? This is how I solved it for now, but it’s ugly and inflexible:

class EventCalendar < Page

tag “calendar” do |tag|
path = @request.request_uri.split("/")
p = Hash[:calendar_group => path[2], :calendar => path[3],
:period => path[4]]

end
end

Just hoping to find a better way.

Thanks,

On Jan 21, 2007, at 11:52 PM, Daniel S. wrote:

If you've made a custom route, then that route will be

handled by a

regular rails controller, not a page object.

Loren J.
removed_email_address@domain.invalid


#5

The @request object is made available to a Page, but the tags are not
evaluated within the context of a page. If you have a method on your
page such as:

class MyPage < Page
def monkeys
@request.params[:monkeys]
end
end

Then you could reference that from your tag:

tag ‘monkeys’ do |tag|
tag.locals.page.monkeys
end


From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Loren J.
Sent: Monday, 22 January 2007 5:33 PM
To: removed_email_address@domain.invalid
Subject: [Radiant] Access to params within extension

Can someone give me a leg up? I’m finding it difficult to find
the request.params array anywhere within the Page context. I have setup
a custom route as part of my extension (not for the admin area, but for
the main site) and in that route I have mapped some custom params I
really want to access.

Any ideas… I tried tag.local.parms[], tag.page.param[],
@request.param[], etc.

Looking through the models/page.rb and taggable I don’t see any
place I’d get this from, but I’m hoping I’m missing something.

Thanks,

Loren J.
removed_email_address@domain.invalid