Thanks for the answers.
The possibility of capturing query parameters is not limited to
addressing different part of pages, but it could be useful in many ways,
I hope this possibility will be included in standard radiant distribution.
In this case I used it to include static html pages into radiant
generated pages.
I have a customer that decided one of his emplyee MUST do some pages
using an editor like nvu. (Learning to use radiant cms is too difficult
for her)
But the rest of the site is generated from radiant, menu and pages etc.
For the moment the tag is customised to my needs, but I think it could
be easily modified to any needs.
First of all I modified the site_controller.rb according to this post
http://lists.radiantcms.org/pipermail/radiant/2007-February/003480.html
Then I created a custom tag
...
require 'net/http'
require 'uri'
tag 'inner_site' do |tag|
# site is the url of the site I want to include risposta is the html
page I will get back
site = tag.attr['site']
risposta=""
# this is the radiant pag with "inner_site" tag for example
http://www.mysite.org/including
# the page "including" shoud be simply <r:inner_site
site="http://radiantcms.org" />
server=request.env['PATH_INFO']
# this caputures the query string parameter (it should be made better
capturing all parameters in a hash with name and value, bu for the
moment it woks) The var @pagina contains the stati html page I want to
include. i.e /html/iniziative.html
tag.globals.page.request.params.each do | param |
@pagina = param[1].to_s.dup
end
if site
url = URI.parse(site)
res = Net::HTTP.start(url.host, url.port) {|http|
@pagina ? http.get(@pagina) : http.get("/html/iniziative.html")
}
# here I replace every internal link with a link to the radiant page
adding in the url the query string for the new page
#external links (those starting with http://) are leaved unchanged
# this part need a lot of work to be useful in every situation (pages
made with mac osx have different new line charachter, there should be a
better way to control if the link is internal or external) but form my
needs work enought.
# images and css paths are unchanged, so you will not see images and css
formatting
res.body.each_line {|line|
risposta+= line=~/http/ ? line :
line.gsub(/href="(.*)"/,"href=\"#{server}?pag="+'\1"')
}
end
risposta
end
now you can use this form to include radiant site in your page
http://www.mysite.org/including?pag=/index
--
Francesco Lunelli
Ymir s.r.l.
Viale Verona 190/11
38100 Trento
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant