Jump to:

23552 Posts in 19349 Topics by 2891 members

General Questions

SilverStripe Forums » General Questions » "home" & Translatable

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

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

Page: 1 2
Go to End
Author Topic: 3176 Views
  • dkwad
    Avatar
    Community Member
    2 Posts

    Re: "home" & Translatable Link to this post

    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

  • pst
    Avatar
    Community Member
    9 Posts

    Re: "home" & Translatable Link to this post

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

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: "home" & Translatable Link to this post

    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.

  • pst
    Avatar
    Community Member
    9 Posts

    Re: "home" & Translatable Link to this post

    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.

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: "home" & Translatable Link to this post

    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]

    3176 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.