Jump to:

23472 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Translating only certain pages

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
Go to End
Author Topic: 355 Views
  • Rod
    Community Member
    12 Posts

    Translating only certain pages Link to this post

    Hi there,

    I need some advice please.

    I am building a website which will be aimed at customers in NZ, UK, and AUS. The default language is NZ, and this is set in _config.php

    95% of the website will be exactly the same for all visitors, however for each country there will be one or two pages which are either not relevant (so should not display in menus) or will have slightly different content.

    I had started using the Translatable extension, but it seems like this is really only suitable if you want to have different versions of the whole site, whereas in my case it is only a couple of pages that will be different. It seems silly to set up many versions of all pages with different URLs as it would only be a few pages that would be different from country-to-country.

    So here is my current thinking:

    • I will create new HTMLEditorFields in the CMS called "UK Content", "Australian Content" etc.
    • I detect the visitor's country with this method: http://hdrlab.org.nz/projects/silverstripe-php-projects/getting-and-using-the-visitor-s-country/
    • In my page template(s), I do a check: if the visitor's country is UK or AUS, and there is content in the relevant CMS field, show e.g. $UKContent. Otherwise show $Content.
    • Create CMS checkboxes "Don't show in NZ", "Don't show in UK" etc. Add this condition to nav menu loops so that only pages available in that country show.

    Is this a good/bad idea? Any advice greatly appreciated, as I have not found any examples out there of others doing this. I'm not great with PHP so any sample code would be helpful too!


Page: 1
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.