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

Translating only certain pages


Go to End


1024 Views

Avatar
Rod

Community Member, 12 Posts

23 August 2011 at 9:57am

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! :D

Thanks!
Liam