The power of flexibility lays in overwriting resources for each website. The resources include files, templates, text, configuration. This feature provides a unique look and behaviour across different websites because the platform fetches webwite's own resources to alter its look and behaviour instead of using default. The platform operates on the site identifier (which is unique per website) to load resources from a database or WAR package while rendering pages, pictures, serving files etc. Each website has a unique site identifier configured in the database which the platform uses to load resources specific to this website.
Site identifier or site
The term site may sound misleading provided it has nothing to do with web. It acts as resources separator within a database. Same resource may exist in a database in several versions (differ by site column) and the platform selects its proper version based on supplied parameters. Resource site is a short identifier usually not longer than 3-5 symbols. It combines the resource origin and optional category (such as language), for example xx1 or mh2.
Key and chain
The key refers to the short version of resource site described above (site identifier or site key). The chain (site chain) is dot-separated sequence of one or more keys. Key example is xx1, chain example is xx1.mh1.mh2.
The chain is what the platform operates upon when selecting a proper resource, chains separate and overwrite resources. The platform is working on a chain from right to left trying to load a resource. If the resource is loaded it is returned, otherwise the platform tries with the next key in the chain, for example:
pub.xx1.xx2 → is there xx2 resource? no → is there xx1 resource? yes → return xx1 resource
Key format is letters+digits. Letters identify resource origin and digits divide those further into categories. [mh] means the resource is for holiday-estates.eu website [mh] and it is in Russian . This example is based on several database settings defined for one particular platform installation.
- Read from the database setting which also contains additional information such as locale appended to chains (eg. xx2=xx1.xx2:ru). to select the proper site based on user geo location. The default root site is the first in the setting - it is used when the platform is unaware of the current site or tries to load default resource from its multilingual versions (eg. SEO is not multilingual so the default resource is used).
- Domain (website) has its own pure chain (eg. pp.pa.dom - without digits) which is mixed with root sites to provide complete chains (letters+digits) utilized by the platform. The domain owns just the last key in its chain (eg. dom), everything before it are template keys for the platform to load if dom resources are not present.
- sys is a system key queried separately which can only be used for internal platfrom needs, never exposed to the outside world. Most of the database settings are sys.
- pub is a public key which is appended to every chain when loading database resources. If a resource cannot be loaded by the chain its pub version is loaded.
- Sites configured in the database, the only hardcoded assumption is that the root site key is 2 letters plus digits (eg. xx1). Aside from that, the platform operates on the database settings when building and linking its chains.
When a user opens a page the platform queries requested domain from the database and creates a chain map. This map contains all possible keys and chains built from the domain, root, extra sites. The platform then uses this map to fetch a chain by key and vise versa. Chain map is stored in user's session and it contains inner maps which link keys with chains. User's requests usually supply a key but the platform can only operate on chains while fetching resources, this is where it queries the map to find the chain by the supplied key and then loads resources.