Daniel!
Thanks for trying to help.
I must admit my ruby-kungfu is weak.
Your suggestion on letting the tag know about the request seems to be
right,
but when I did what you suggested:
require "app/models/page_context"
class PageContext
alias initialize_before_reformhaz initialize
def initialize(page)
initialize_before_reformhaz(page)
globals.request = page.request
end
end
in my reformhaz_extansion.rb
I got
SystemStackError in SiteController#show_page
stack level too deep
vendor/extensions/reformhaz/reformhaz_extension.rb:29:in
`initialize_before_reformhaz'
vendor/extensions/reformhaz/reformhaz_extension.rb:29:in
`initialize_before_reformhaz'
vendor/extensions/reformhaz/reformhaz_extension.rb:29:in `initialize'
app/models/page.rb:226:in `lazy_initialize_parser_and_context'
app/models/page.rb:126:in `render'
app/models/page.rb:121:in `process'
Since I have a similar experience with reopening and redefining methods
in the Page class, albeit that explodes in a different way, I just
boldly edited PageContext directly to have-a-look.
The exact situation is : root page <r:find>s the products page and
renders
it's body. The outcome is the same: the tags in product can't read the
request
to determine the offset and length. It's only okay if I redirect to
/products
and the first page that gets dug up from the db is my ProductPage.
I guess I would have to tweak r:find too to pass down the info to the
found one.
(the way Kaleb did with the snippet up front)
The other way is to hack Page to store the request in a class variable.
This isn't bad -methinks- since we have the luxury of having our whole
process to answer a lonely request. Another request gets it's own
interpreter.
You're right about that I might just need my own controller to handle
the
search-paging request, and then feed the params to the tags, but so far
I can
only do this for the directly requested page.
My only true headache is: I just can't reliably redefine methods in Page
and
PageContext. On SiteController on the other hand it does work. Why?
Daniel Sheppard wrote:
> Do you need access to the request from the page objects or from the
> tags? If it's just the tags:
>
> class PageContext
> alias __old_initialize initialize
>
> def initialize(page)
> __old_initialize(page)
> globals.request = page.request
> end
> end
>
> If you need it set on the page object for one of your tags to work, just
> do the setting in that tag.
>
>
> Dan.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant