Url parameters

s it possible to capture query parameters and use them inside tags?
For example if I have a URL like this
http://www.mysite.com/books?lang=it can I caputre the lang parameter and
pass it to some tags?
Having a page made with to parts “it” and “eng” I could decide wiche
part show in a way like this:
<r:content part=“LANG” /> where lang is the url parameter captured.
But this could be useful in many other situations I think.
Thanks to everybody
Francesco L.


Yes, if the page is uncached. Another option would be to use the
language_redirect idea where you have multiple sub-sites for each
language, but I know that’s not ideal in terms of reuse. Anyway,
inside a tag definition, you should have access to the request and
response variables. There are discussions about this previously on
the mailing list, just do a search at


Francesco L.
If you’re willing to get down and dirty and write and extension, I’ve
had some thoughts on how to implement a better langauge
extension - the different trees provided by the language redirection
extension don’t strike me as particularily friendly to keep up
to date, and your suggestion is pretty close to what I’ve got in my

Basically, there would be a parent ‘language selector’ page, all
children below that point can have differently languaged parts.

When the parent page’s find_by_url method is called, it sets
LanguagePage.language = ‘en’ (not 100% sure on the best mechanism, but
that’ll do off the top of my head)

When children are asked for a page part, say ‘body’, they would first
look for ‘body_en’ and only revert to ‘body’ if that does not

So you’d have a single tree of pages, but they would be served through
different urls:


I’ve got no real use for international stuff in the forseeable future as
I run a local site for local people, so I don’t think I can
be bothered actually writing the code to do this, but I’ve got it all
pretty much in my head if anybody wants some further detail to
pursue it themselves or some monetary motivation for me to write it.


When children are asked for a page part, say ‘body’, they would first look for ‘body_en’ and only revert to ‘body’ if that does not

So you’d have a single tree of pages, but they would be served through different urls:


I think its a interesting point of view. So all your pages have parts
for all the languages that your site supports.

In the request you can get the browser default language, dont you? So
the default language of the site will be the browser’s default. After
the page is loaded, the user can select an specific language in the
litle flags :).

Probably I will need something like this in a close future. It’s ok to
implement this as an extension??


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

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

this is the radiant pag with “inner_site” tag for example


the page “including” shoud be simply <r:inner_site

site=“http://radiantcms.org” />


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

res.body.each_line {|line|
risposta+= line=~/http/ ? line :

now you can use this form to include radiant site in your page

Francesco L.
Ymir s.r.l.
Viale Verona 190/11
38100 Trento