Forums / Install & configuration / More than one multilingual site on one ezpublish instance

More than one multilingual site on one ezpublish instance

Author Message

Matthew Carroll

Wednesday 29 November 2006 9:37:11 pm

Hi

I've scratched my head about this one a number of times before, and never found a solution. I wonder if I'm missing something. Here's what I would like to achieve:

(uri --> siteaccess name)

www.example.com/en --> siteaccess1
www.example.com/fr --> siteaccess2
www.example.org/en --> siteaccess3
www.example.org/fr --> siteaccess4

As far as I can tell:

1. uri matching is out, since I can't differentiate 1 from 3
2. host matching is out, since I can't differentiate 1 from 2 (or 3 from 4)
3. port mapping is irrelevant - i need everything on 80
4. servervar... well, this is a mystery to me - does it hold a secret i could use?

This seems like a fairly simple thing to want to do, but I can't work out any way to do it.

At the moment I have host-based siteaccess selection as follows:

en.example.com --> siteaccess1
fr.example.com --> siteaccess2
en.example.org --> siteaccess3
fr.example.org --> siteaccess4

This is far from ideal, due to (1) a bug in static caching that means static cache doesn't work with host based siteaccess selection, and (2) that cookies are tied to the host name and so people have to log in again after switching languages.

I'd like to move away from subdomains, to putting everything in the url, but with more than one multilingual site, and a desire to keep urls neat (ie NOT use a hack like www.example.com/en1/ and www.example.org/en2/) I'm at a loss as to how.

Any ideas?

Thanks
Matthew

http://carroll.org.uk

Jacobo Quiles

Thursday 30 November 2006 12:27:35 am

Hi

You can do that by creating multiple siteaccess. For example:

settings/siteaccess/yoursite (english)
settings/siteaccess/yoursite_es (spanish)
settings/siteaccess/yoursite_fr (french)

I explain you how to setup yoursit_es for example:

Inside the yoursite_es folder, create a file called site.ini.append.php. On a 3.8.6 version of eZ Publish it must contain something like this:

Example of site.ini.append.php for your default siteaccess (yoursite) in english:

<?php /* #?ini charset="utf-8"?

[DatabaseSettings]
DatabaseImplementation=ezmysql
Server=localhost
User=your_mysql_username
Password=your_mysql_password
Database=your_database_name

[SiteSettings]
SiteName=Your_site_name
LoginPage=embedded
IndexPage=/content/view/full/2
 
[SiteAccessSettings]
RequireUserLogin=false
ShowHiddenNodes=false
 
[DesignSettings]
SiteDesign=your_custom_design_folder_name
AdditionalSiteDesignList[]=base
AdditionalSiteDesignList[]=standard
 
[ContentSettings]
TranslationList=
ViewCaching=disabled

[RegionalSettings]
Locale=eng-GB
ContentObjectLocale=eng-GB
TextTranslation=enabled

[FileSettings]
VarDir=your_var_folder

/* If you work with extensions */

[ExtensionSettings]
ActiveAccessExtensions[]=your_extension_folder_name

*/ ?>

Example of site.ini.append.php for yoursite_es siteaccess (spanish):

<?php /* #?ini charset="utf-8"?

[DatabaseSettings]
DatabaseImplementation=ezmysql
Server=localhost
User=your_mysql_username
Password=your_mysql_password
Database=your_database_name

[SiteSettings]
SiteName=your_site_name
LoginPage=embedded
IndexPage=/content/view/full/2

[SiteAccessSettings]
RequireUserLogin=false
ShowHiddenNodes=false
 
[DesignSettings]
SiteDesign=your_custom_design_folder_name
AdditionalSiteDesignList[]=base
AdditionalSiteDesignList[]=standard
 
[ContentSettings]
TranslationList=
ViewCaching=disabled

[RegionalSettings]
Locale=esl-ES
ContentObjectLocale=esl-ES
TextTranslation=enabled
TranslationExtensions[]=your_translations_extension

[FileSettings]
VarDir=your_var_folder

/* If you work with extensions */

[ExtensionSettings]
ActiveAccessExtensions[]=your_extension_folder_name

*/ ?>

Now all you need to do is activate the new siteaccess in settings/override/site.ini.append.php:

<?php /* #?ini charset="utf-8"?

[Session]
SessionNameHandler=custom

[SiteSettings]
DefaultAccess=your_site_name
SiteList[]=your_site_name

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]=yoursite
AvailableSiteAccessList[]=yoursite_es

MatchOrder=uri
HostMatchMapItems[]

[MailSettings]
Transport=sendmail
AdminEmail=your_admin_email

*/ ?>

Now clear all caches and try to access to both siteaccess:

www.example.com/yoursite
www.example.com/yoursite_es

Cheers.

Microblau SL
http://www.microblau.net

Matthew Carroll

Thursday 30 November 2006 10:33:15 am

Hi Jacobo

I think you misunderstood my question. I know how to make a siteaccess selection based on the url, as in your example. What I want is to have two sites on different domains, mapped to separate siteaccesses, using a combination of both the domain AND the url to make the selection. Maybe it's better written like this:

www.example.com/en --> settings/siteaccess/site1_en
www.example.com/fr --> settings/siteaccess/site1_fr
www.example.org/en --> settings/siteaccess/site2_en
www.example.org/fr --> settings/siteaccess/site2_fr

...do you see the challenge now?

Matthew

http://carroll.org.uk

Jacobo Quiles

Friday 01 December 2006 4:11:55 am

Ok, sorry i misunderstood. Can see the point now but can't help much.

Microblau SL
http://www.microblau.net

Xavier Dutoit

Saturday 02 December 2006 1:25:00 am

Hi,

I had the same problem and didn't find any solution.

What I found was to install ez into one directory:

/var/www/siteA

then create a /var/www/siteB

ln -s every folder but the settings one,
ln -s every folder and file into settings but override,
write the settings/override/site.ini. append for siteB
ln -s the other

X+

http://www.sydesy.com

Claudia Kosny

Saturday 02 December 2006 2:49:51 am

Hi Matthew

Not sure whether the following works, but I think it is worth a try:
I would just try to more or less hardcode it in the access.php. The function accessType takes some parameters provided by the index.php and returns an array containing the name and the type of the siteaccess. If you fetch $_SERVER in there you can certainly find out which siteaccess should be used, so you have the name of the siteaccess. Determining the best type of the siteaccess might pose a problem, as this is used in some (not many) other php files and has different effects. But as there are only a few types, maybe you can just try the different types out.

Another idea would be to use the servervar matching. I don't know whether you can create server variables using htaccess but it works with environment variables. So set some rules in the htaccess that set an environment variable depending on the url and change access.php to check for env instead of server.

Please note that I do not have the slightest idea whether any of these approaches works or how safe it is to use...

Good luck

Claudia

Matthew Carroll

Saturday 02 December 2006 11:15:31 am

Xavier - thanks for the sym-linking idea... I'd also thought of trying to use an apache alias for settings/override, but not tried it yet. I already have a sym-link forest keeping the settings for all our individual sites separate from the code base to facilitate easy upgrades when a major release happens.

Claudia - I'd thought of patching access.php, but I'd really like to avoid hacking the ez codebase.

Thank you both - you've confirmed at least that this seemingly obviously setup can't easily be achieved, so I will file a feature request.

Matthew

http://carroll.org.uk

Matthew Carroll

Saturday 02 December 2006 11:57:54 am

http://issues.ez.no/9690

http://carroll.org.uk