Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

"home" & Translatable


Go to End


13 Posts   6590 Views

Avatar
dkwad

Community Member, 2 Posts

11 December 2009 at 10:13pm

Hi Chris,

Thanks very much for a very full reply, totally appreciate the time taken here to help. I will defo give this a shot and let you know how I get on.

Best wishes, merry christmas

Avatar
pst

Community Member, 9 Posts

13 December 2009 at 5:06am

Hey Chris,

thank you for this post. It really helped me a lot since I wanted to implement exactly the same using a .com and a .de domain. Now I did not have to because I could just use your code. Thanks a lot.

I have one question though. It seems as if since Silverstripe doesn't really know about the domains it's not possible to have two languages of a page using the same url.

Example: mydomain.com/home and mydomain.de/home

Am I missing something here or is this really not possible, which would be a real problem for me right now...

Avatar
ChrisBryer

Community Member, 95 Posts

15 December 2009 at 5:23am

glad its helping..
as far as urls, all domains point to the same base install and same database. silverstripe makes sure urls are not redundant so i dont really see a good way around that one.. I know SiteTree writes the URL in the onBeforeWrite method, which you may be able to override and test for unique url's within a locale. I thought about common url's between domains too, but if you are in germany, you'd rather see things written in your native language, so instead of 'home', you'd have 'haus' so the problem doesnt really exist if you translate urls too. the caveat is special characters like umlauts and the entire Japanese / Chinese languages.

Avatar
pst

Community Member, 9 Posts

16 December 2009 at 11:42pm

Thanks for the reply.

I have it working so far. I will use /start for the German home. Since homepage translates to Startseite. I have some other URls I might need to think about a good new name but thats ok.

I am right now working on getting all translations linked on each page using the right domain. Already kind of working. But think there might be a problem with the sitemap. I don't want all pages to appear in the sitemap using the same domain. And it's also not good to do so.

A sitemap on the .com domain should only containt URls to pages on the .com domain.

Will post my code here, if anyone is interested.

Avatar
ChrisBryer

Community Member, 95 Posts

19 December 2009 at 9:15am

i just got around to fixing that ?lang=com problem.. (on the default locale's homepage, the /home redirects to /?lang=com). here's better .htaccess code:

RewriteCond %{HTTP_HOST} ^www\.(domain1|domain2|domain3)\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^www\.(domain1|domain2|domain3)\.com$ [NC]
RewriteRule ^(.*) $1?lang=%2&%{QUERY_STRING}

in this case, .com is the the top level domain. if your top level domain is .de (and mysite.de/home redirects to mysite.de/), change the second line to
RewriteCond %{HTTP_HOST} !^www\.(domain1|domain2|domain3)\.de$ [NC]

Go to Top