A SilverStripe module which allows you to have contents specific for locations, and serve these contents for users by checking their location.
Use composer to install the module.
composer require silverstripers/continental-content dev-master
After installing the module on your SilverStripe site, you have to manually specify which data objects you want the module to decorate with in order to have different contents.
SiteTree:
extensions:
- ContinentalContent
You have the freedom to decorate any object, in this YAML i am decorating the SiteTree object, which is the base object of SilverStripe pages.
Once you've done the above you can set up the locations which you want to have different contents for.
ContinentalContent:
continents:
BC:
Country: CA
SubDivision: BC
AB:
Country: CA
SubDivision: AB
ON:
Country: CA
SubDivision: ON
If you want to use contents for a group of location then you can group them by.
ContinentalContent:
continents:
Europe:
Country:
- GB
- GE
- FR
NZ:
Country: NZ
AU:
Country: AU
In this example Europe will be used for GB, GE, FR countries.
If there are fields which you dont wish to customise for each of the locations, you can specify them as configs
ContinentalContent:
exclude_field_names:
- SiteTree.Title
- URLSegment
The above removes URLSegment from any of the data objects you have a field called URLSegment, but it removes Title only from SiteTree.
If you want to have separate urls for each location eg: site.com/uk/home, site.com/nz/home etc. You can allow that with another config.
ContinentalContent:
custom_urls: 'Y'
Sometimes this can happen, if you are using several load balancers to and have your website behind them and your load balancers
wont pass the end clients IP. In this can use can set up a form and ask your users to select the location they are coming from.
ContinentalContent:
proxy_ip: '0.0.0.0'
set up the IP which your webserver gets all the time.
make a function like the following in Page_Controller class.
function LocationDetected(){
return !(ContinentalContent::IsViewingThroughProxy() && ContinentalContent::CurrentContinent() == CONTINENTAL_DEFAULT);
}
If the above returns true you can draw a location selector to select the visitor's location.
The module only supports max mind, upload the max mind City data base from the site config.
There are several options to debug the configs. You can pass three get vars
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem