Measurable Success «10 Checkpoints for Future-Proof Enterprise CMS» White Paper
Measurable Success - White Paper

SiteContext

New in 1.18.0

SiteContext

A SiteContext provides access to CMS objects, taking their respective website assignment into account. It can be used to retrieve, search and create CMS objects (see below).

Background

In a multi-site-enabled Scrivito application, every CMS object has a siteId. A site is the collection of all CMS objects that have the same siteId.

A multi-site Scrivito application is executed in the context of a specific site, derived from its current browser location. Scrivito.Obj can be considered the SiteContext of the current site, meaning that Scrivito.Obj limits access to CMS objects to this current site.

SiteContext types

Actually, there are two types of SiteContext, each one with a specific site restriction:

The single-site context

Scrivito.Obj.onSite returns the single-site context for the site specified by the siteId passed to it. Also, Scrivito.Obj represents the single-site context of the current site.

The context restricts access to CMS objects belonging to the site specified by the siteId or, respectively, the current siteId. Its methods return exclusively Obj instances of this site.

On creation of a CMS object (create, createFromFile), it gets assigned to the site of the context.

The all-site context

This special site context provides access to any Obj instance, regardless of its site, as opposed to the above-mentioned current site context Scrivito.Obj.

Note that this is the only site context that can be used in siteIdForUrl to dynamically identify the ID of the current site based on the site’s base URL.

Static method summary