# Access to params within extension

**URL:** <https://www.ruby-forum.com/t/access-to-params-within-extension/82900>\
**Category:** Radiant CMS\
**Created:** [January 22, 2007, 7:35am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900 "2007-01-22T07:35:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [January 22, 2007, 7:35am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900/1 "2007-01-22T07:35:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [January 22, 2007, 7:59am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900/2 "2007-01-22T07:59:02Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [January 22, 2007, 8:11am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900/3 "2007-01-22T08:11:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [January 22, 2007, 8:18am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900/4 "2007-01-22T08:18:05Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [January 22, 2007, 8:13am UTC](https://www.ruby-forum.com/t/access-to-params-within-extension/82900/5 "2007-01-22T08:13:04Z")

</div>

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](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
