Forum: Radiant CMS Access to params within extension

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Loren J. (Guest)
on 2007-01-22 08:35
(Received via mailing list)
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
Daniel S. (Guest)
on 2007-01-22 08:59
(Received via mailing list)
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
Loren J. (Guest)
on 2007-01-22 09:11
(Received via mailing list)
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
Daniel S. (Guest)
on 2007-01-22 09:13
(Received via mailing list)
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
Daniel S. (Guest)
on 2007-01-22 09:18
(Received via mailing list)
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
This topic is locked and can not be replied to.