Creating a Site with Multiple Contexts
17 Dec 2015
To understand how to set up a multi-context Site, consider the following example.
We want to create a Site with both English and French contexts, with the context being displayed determined by a user’s browser language preference.
Note that if you are using any sort of proxy/accelerator caching in front of your Squiz Matrix instance, switching context based on the browser language will most likely not work. It will only work if your caching layer supports multiple cache entries per URL, or if the pages aren't cacheable at all.
To set up this multi-context Site, follow the steps outlined below.
- On the Context Configurations screen, create a new Alternative Context for the French version of your Site. The system’s Default Context will act as the default English Version of the Site.
- Edit the French Version context, creating a new condition of type Accept-Language request header.
- On the Accept-Language request header options, select French as the language to match and enter a quality value of 1.0. This will mean that only users whose main language preference is French will view this context.
The English and French version contexts will be listed in the Current Contexts section, as shown in the figure below.
- Create a Site, with a Standard Page as the Index page.
- Edit the contents of the Standard Page with English text and images.
Now, select the French Version context in the Change Context list in the info bar, shown in the figure to the right. The edit contents page will refresh, containing the English content previously entered.
- Alter the contents of the Standard Page to create a French version of the page.
Once you have Committed your changes, you will be able to switch between the English Version and French Version contexts, noting that they retain their language specific content, as shown in the figures below.
- When a user accesses your Site, the context displayed will be determined by their browser language preference. A user with a main browser language of French will be shown the French Version context of the Site, while all other users will be shown the default English Version context. The different language versions are shown in the figures below.