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.
839b1e791357ce8dd935c93d4b7a0c9a?d=identicon&s=25 Loren Johnson (Guest)
on 2007-01-22 07: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 Johnson
loren@fn-group.com
1c1e3bdfe006a22214102fcd6434a012?d=identicon&s=25 Daniel Sheppard (Guest)
on 2007-01-22 07: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: radiant-bounces@lists.radiantcms.org
[mailto:radiant-bounces@lists.radiantcms.org] On Behalf Of Loren Johnson
  Sent: Monday, 22 January 2007 5:33 PM
  To: radiant@lists.radiantcms.org
  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 Johnson
    loren@fn-group.com
839b1e791357ce8dd935c93d4b7a0c9a?d=identicon&s=25 Loren Johnson (Guest)
on 2007-01-22 08: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 Sheppard wrote:

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

Loren Johnson
loren@fn-group.com
1c1e3bdfe006a22214102fcd6434a012?d=identicon&s=25 Daniel Sheppard (Guest)
on 2007-01-22 08: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: radiant-bounces@lists.radiantcms.org
[mailto:radiant-bounces@lists.radiantcms.org] On Behalf Of Loren Johnson
  Sent: Monday, 22 January 2007 5:33 PM
  To: radiant@lists.radiantcms.org
  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 Johnson
    loren@fn-group.com
1c1e3bdfe006a22214102fcd6434a012?d=identicon&s=25 Daniel Sheppard (Guest)
on 2007-01-22 08: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: radiant-bounces@lists.radiantcms.org
[mailto:radiant-bounces@lists.radiantcms.org] On Behalf Of Loren Johnson
  Sent: Monday, 22 January 2007 6:10 PM
  To: radiant@lists.radiantcms.org
  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 Sheppard wrote:


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

    regular rails controller, not a page object.



  Loren Johnson
  loren@fn-group.com
This topic is locked and can not be replied to.