Re: [Radiant] need a to tweak a page based on server name

2010-02-09 Thread Brett Rasmussen
I had to do this same sort of thing recently.  I didn't find anything out
there that just took care of it, so I rolled my own solution.  It wasn't a
very simple and straightforward thing.

In my case, the pieces on the given pages that needed to change were going
to vary based on country, and we have different domains for different
countries.  I used the multilingual_pages extension to create different
slugs for the same page but showing different content based on the slug.

Then I created a database table and model class that contained mappings
between domains (I actually did it with hostnames for more flexibility) and
languages.

Then I monkey-patched the rendering process in the Page class to look up the
domain the user comes in on in that database table.  If there's a match, it
gets the relevant language and looks for a slug for the requested page that
is associated with that language.  If so, it redirects to that slug.

What you wind up with is a "default" slug that you can point everyone to in
your links and such, and then a different slug for each variation of that
page.  Your program redirects the user to the alternate slug based on the
requested domain name.  The separate slugs make the whole thing cache safe.

If it's helpful for you, the methods in Page that I had to monkey-patch were
process, find_by_url, cache?, headers, render, and response_code.  Some of
those had already been monkey-patched by multilingual_pages, so they got
double-monkey-patched by me, and I also had to monkey-patch
needs_language_detection? from multilingual_pages.

All of this stuff would make for a really good radiant extension to add to
the extension registry, or even just a patch for multilingual_pages, but I'm
short on time.

Hope this helps you.

- Brett


On Mon, Feb 8, 2010 at 2:13 PM, Laurent Julliard  wrote:

> Hello,
>
> We have a single radiant site that is being accessed from two distinct
> domain name (e.g www.domain1.com and www.domain2.com). In a few places
> we need to customize the content of the page depending on the server
> name that is invoked to access the site. I have looked into various
> filters, plugins, etc... and could not find a way to do this.
>
> Any idea on how we could achieve this ?
>
> Thanks for your help
> ___
> Radiant mailing list
> Post: Radiant@radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> Radiant: http://radiantcms.org
> Extensions: http://ext.radiantcms.org
>
___
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org


[Radiant] need a to tweak a page based on server name

2010-02-08 Thread Laurent Julliard
Hello,

We have a single radiant site that is being accessed from two distinct 
domain name (e.g www.domain1.com and www.domain2.com). In a few places 
we need to customize the content of the page depending on the server 
name that is invoked to access the site. I have looked into various 
filters, plugins, etc... and could not find a way to do this.

Any idea on how we could achieve this ?

Thanks for your help
___
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org