Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Use this page as the 'home page' for the following domains

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: 2062 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    Use this page as the 'home page' for the following domains Link to this post

    hi

    i have multilanguage page
    i want that the german version has different domain from the english

    i enter german domain to the german varsion HomePage into "Use this page as the 'home page' for the following domains:" field but it doesnt work
    should i have redirect domain DNS to my server ? or redirect to the german home page addres: www.mysite.com/de-home-page ?

  • Cristian
    Avatar
    Community Member
    8 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    Hi,

    Did you figure out what to do, I'm having the exact same problem.

    the HomepageForDomain only work with the default Locale... not the translated one.

    thanks,
    Cristian

  • snaip
    Avatar
    Community Member
    180 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    hi

    no i didn't
    it is so stupid that it doesnt work with translate

  • Futureal
    Avatar
    Community Member
    9 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    does anyone know if this is solved yet?
    I want to set a different homepage for the non-default locale?

    Thanks.

  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    hey everyone,
    we have been discussing this on the core dev discussion group. currently translatable is part of the core code but ingo pulled translatable out of sapphire and cms for future versions of silverstripe so its more easy to update and fix without hacking core code.

    I built a little module that should do what you need, located at https://github.com/cbryer/Translatable-Domains. it needs some testing and a little more work done on it, but its working pretty well for me. this code lets you register top level domains with specific locales, and the module makes sure that you view for example, a german page while on a german TLD. just point all the domains at the same silverstripe directory so they see the same thing and the module handles the rest.

    i also included directions on how to set up different localhosts to simulate different tld's so you can test locally.

    also, this could easily be re-written to support subdomains instead of top level domains. the idea is that when this is stable, it will be merged with the new translatable module and this functionality will be built in.

    let me know how it goes, any questions, feedback, etc.
    -Chris

  • jpmcc
    Avatar
    Community Member
    14 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    Hi Chris,

    This looks great and exactly what I need. Just found a slight issue though (and I know this is still work in progress), but if you try and access a page that is not in the current locale, rather than a 404, the system tries to send you to /<page_name> without any domain part (which for some browsers either sends you to Google or gives a browser generated 404.

    Any ideas?

    Thanks for the work on this.

    Jason.

  • jpmcc
    Avatar
    Community Member
    14 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    Hi,

    Turns out to be my fault for not specifying the default domain for the default locale. Doing that and it does exactly what it is supposed to.

    Cheers,
    Jason.

  • jpmcc
    Avatar
    Community Member
    14 Posts

    Re: Use this page as the 'home page' for the following domains Link to this post

    Just a quick update.

    Something to be aware of. When using Translatable, it automatically inserts alternate meta tags (when your meta tags are generated automatically), to point to any additional live translations of a specific page. However, it doesn't include the domain portion. Therefore whatever follows the link will be taken back to the current version of the page and not the alternative one.

    This is because the current domain is obviously assumed, and with the SingleLocalDomain in place, it is detected that the alternate page should not be displayed for the current domain so back to the original page.

    Just as a work around, I have overridden the MetaTags function for my base page object, filter out the <link rel="alternate" ... /> tags and inserted my own. The code used to generate them is essentially the same as the code used by Translatable, however, I grab the list of available domains from TranslatableDomain and use that to help construct the links.

    public function MetaTags($includeTitle = true){
       //remove the alternate meta and insert our own version
       $meta = preg_replace('/<link\srel="alternate".*\s\/>/i', '', parent::MetaTags($includeTitle));
       $meta .= $this->alternateMeta();
       return $meta;
    }

    The alternateMeta function just ensures the domain portions are added.

    I know you could reduce that to one line, but sometimes having an intermediate var helps the debugging process and makes it a little more legible.

    Cheers,
    Jason.

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