Using contexts

Editing content with contexts

The context switcher

When alternate contexts have been created, the context switcher will appear in the admin mode interface’s top header.

context switcher closed

This tool allows you to enter either the default context or any available alternate contexts when editing and reviewing assets. By selecting an alternate context, you can establish alternate versions of an asset by creating unique context-specific content. By default, the system will display all assets in the default context.

Click on the Context switcher button to enter into a different context. A list of available contexts will become available.

context switcher open

Clicking on an option from the list will switch the interface to the selected context.

If you have selected an alternate context that has not yet been customized, the information and content displayed will be the same as that in the default context. Any changes made to an alternate context will remain unique to that specific context.

You can set the back-end context being edited by appending the query string parameter sq_action=set_backend_context&sq_context_name=contextname to the URL of the asset. You can also utilize this parameter in inline edit mode interfaces to switch between the contexts being edited.

Editing screens and content in an alternate context

Once you enter into an alternate context, all fields and editable areas will be read-only until you specifically select to customize a screen for that context.

For example, if you enter an alternate context and visit the Details screen of an asset, all fields will be read-only with a checkbox option to customize the current screen.

details screen context

If you select this option and save the screen, only the fields that support context customization will be available for editing.

details screen context customised

Similarly to when you edit the contents of assets that support components, such as standard pages, you can also customize each component’s contents.

content container context customised

Reverting content for an alternate context

Screens and content customized for an alternate context can also be reverted to use the default context’s values.

For example, you can clear the Customize checkbox if you want the metadata of an asset to no longer have customized values for the current selected alternate context in which you are.

The system will warn you that this will delete all the customized values for that context and cannot be undone.

context revert

Keyword replacement values across contexts

You can return keyword replacement values across the contexts of a site through the following format:

%<asset_keyword>^context:<context_name>%

Where <asset_keyword> is a contextable keyword replacement and <context_name> is the name of the context to return the asset value from.

For example, the keyword replacement:

%asset_attribute_name^context:french%

Will return the name of the asset in the french context.

Setting metadata field values and defaults across contexts

When using alternate contexts within a system, you can configure metadata values individually over multiple contexts, and you can set default values for each of these contexts.

You must manually regenerate metadata on each newly created context before it is applied.

Setting metadata values and defaults over multiple contexts is done similarly to editing an asset’s contents, as shown earlier in this chapter.

Use the Context switcher button to select a context for which you want to edit the metadata.

If you have selected an alternate context that has not yet had metadata values and defaults edited, the information displayed will be the same as that on the default context. Any changes made to the metadata field values and their defaults will remain unique to the selected context.

The field name and metadata options on a metadata field’s details screen are not contextable.

Alternatively, you can configure metadata fields to be non-contextable. This configuration is done using the contextable option on the details screen of a metadata field:

contextable setting

Setting this field to No will maintain metadata values across all contexts. This ability is functional when setting important numeric metadata values for information such as product quantities and pricing in an ecommerce store.

By default, all metadata fields are contextable when they are first created.

Using paint layouts on sites with multiple contexts

When using paint layouts on a multiple context site, these layouts are rendered by the currently viewed context, displaying the paint layout’s corresponding context. This function allows you to customize the contents of the layout for each context.

For example, a site has been created with three contexts: the default English context, a French context, and a Japanese context. A paint layout can display updated information at the bottom of each page, titled Last updated. As the site is in multiple languages, you can configure the paint layout for each context to display this information in the appropriate language.

When a user views the site on the frontend, the site’s context will determine the paint layout displayed. For example, if a user from France views the French context of the site, Matrix will also display the paint layout’s French context.

Contexts on the preview screen

When previewing an asset on the Preview screen, the Context field gives you the ability to switch between the contexts available for the asset. This feature allows you to preview all versions of an asset.

If alternate contexts have not been created in your system, the Context field will appear blank.

When no Context field is available, the system’s default context will always be displayed. The system will display a drop-down list where alternate contexts have been created, as shown:

context previews

The following options are available in the Context field:

Use normal context for this URL

This will display the asset in the base context of the URL being previewed. By default, this will be the system’s default context.

Default context

This will display the asset in the system’s default context.

Alternate context(s)

The available alternate contexts in the system will be listed below the default context. Selecting an alternate context will then preview the asset in that specific context.

To review a context on the frontend, append the query string parameter sq_action=set_context&sq_context_name=name of context to the URL of the asset. You can also clear the context of a page with sq_action=clear_context.

Setting base contexts for site URLs

When alternate contexts have been created, the base Context field is made available on the URLs screen of site assets, allowing contexts to be assigned to specific site URLs. These base contexts will then be used as the default context for that URL and displayed if no alternate contexts' conditions are met. By default, the base context of all URLs will be the system’s default context.

To change the base context of a URL:

  1. Select a context from the list.

  2. Click Save.

This context will then be used as the default context for the site.

Separate URLs for multiple contexts

You can utilize base contexts by creating multiple URLs, catering to specific alternate contexts.

A site has been configured with different URLs for each of its alternate language contexts in the example below. No conditions have been set for these contexts.

base contexts

When the site is viewed on the frontend, each URL will display the selected base context. The configured URLs can then be used as links, allowing users to change the site’s context manually.

Setting the sign-in context for user groups

When you have multiple contexts on a system, it can help to configure certain user groups to be automatically assigned to a specific context when they first sign into Matrix.

For example, if you have a multi-language site with English and French versions and two corresponding user groups of content editors for each language. You can configure these two user groups so that the English content editors will be signed into the system’s English context, while the French content editors will be signed into the French context of the system.

login preference

To set the sign-in context for user groups:

  1. Go to the Preferences screen of the user group.

  2. Select Customize this preference for the Set context on sign-in preference under the User preferences section.

  3. Click Save. An additional field will appear in this section, listing the available contexts on your system in a drop-down menu, as shown in the example above.

  4. Select the context you want this user group to be automatically signed into.

  5. Click Save. The users within this user group will now be signed into the selected context when they first access the system.

  6. Selecting Do not change context on sign-in will sign users in using the context assigned to the URL used to access the system. This preference also assigns contexts to user groups when viewing sites on the frontend

For example, you also have two user groups of registered users (English and French) on this site. Configuring this preference for these two user groups will mean that the English users will be signed into the English version of the site, while the French users will be signed into the french version of the site.

You can set these preferences globally through the Global preferences screen.

Read the Setting and managing global preferences documentation for more information on user preferences.

© 2015- Squiz Pty Ltd