In order to create the hierarchies you first need to configure the variation labels, which should be spawned. At least the source Variation Label has to be configured in order to create the hierarchies.
Important: The creation of the hierarchies will fail if a site exists inside the Variation root site with the same name as one of the variation labels, which is about to be spawned.
The Create Hierarchies button in the UI will create a Scheduled Work Item in the Content Database of the site collection which is later retrieved by the CreateVariationHierarchiesJobDefinition timer job to do the actual creation of the hierarchy.
Per default, the timer job is configured to run once a day between 12 AM and 3 AM - that means a user will usually have to wait until the next day for the hierarchy creation to happen.
Alternatively, a farm administrator can run the job manually at any given time from the central admin site.
What happens during Timer Job execution?
Source variation and target variation top sites are always created one level below the variation root site. Each variation top site is using the site template configured when defining the source variation label.
To change the look and feel between the different top sites you can either use a different theme and/or a different master page.
When the variations hierarchy is first created, only the variation top sites are created. Afterwards you can create the sub sites in the variation source hierarchy. Variants of these sites are then created in the target labels - either automatically or manually.
If sites or pages are created directly in a target label, they will not be part of the variation hierarchy and content in these sites and pages will be independent from other labels.
If a new label is added to the variation hierarchy after the variations hierarchy of the source label has been first created, a new top variation site is created for the new label and in addition, (default setting) pages and sites in the source label are automatically variated to the new label.
Creating the variation hierarchy involved three major steps:
- Create the VariationRoot.aspx landing page which contains the logic to redirect to the different label and configure this page as welcome page for the Variation Root site
- Create the Variation Top site for the source variation label underneath the Variation Root site
- Replicate the site structure and the publishing pages from the Source Variation label to new configured target and not yet spawned variation labels
Here are more details about the three steps:
Configuring the Variation landing page
The Timer Job first verifies if a page with name VariationRoot.aspx exists in the Pages library of the Variation root site.
If this is not the case, it will create, check-in, publish and approve a new Publishing Page at this location based on the VariationRootPageLayout.aspx page layout, which is part of the SharePoint Server Publishing Infrastructure feature.
The last step is to configure the VariationRoot.aspx page as welcome page for the variation root site.
Creating the Variation Top site for the source variation label
The Timer Job first verifies if the top site of the source label already exists and will skip the rest of the steps if yes.
After checking that the top site does not exist, it will disable the automatic spawning of new created sites to the target labels to ensure that the Timer Job responsible to perform the site spawning does not pick up the new site while the hierarchy is not fully created.
The next step is to provision a new publishing site based on site template, locale and language configured in the variation settings. The title of the site will be the configured display name of the variation label.
The new site will then be marked as being a member of the variation hierarchy and a new entry for the site is created in the global Relationships List.
Afterwards the new site is configured as variation top site of the label and the hierarchy of the label will be marked as created.
The final step is to re-enable the automatic spawning of new created sites to the target labels.
Replicating content from source to target labels
This is the most complex step as it is possible to add new labels long after the source hierarchy is created and new sites and pages have been added to the source label it is not sufficient to just replicate the variation top site to the target labels.
Depending on the variation settings, it might be necessary to replicate the following information:
- Just the top level sites
- The whole site structure without pages
- The whole site structure including all pages
The default is to replicate the whole site structure including all pages.
Here is the high-level description of how the replication is done by the timer job. Be aware that some of these operations are also performed in the other timer jobs, which are responsible to replicate only sites or pages:
For each unspawned target label, we perform the following steps:
- Provision the top site in the target label using the same template as on the source label using the Display Name, locale and language configured for the target label
- Ensure that the new site has the same configuration (variation group id, welcome page, features, navigation, UIVersion, Master page, Theme…) as the peer site in the source label
- The new site will then be marked as being a member of the variation hierarchy and a new entry for the site is created in the global Relationships List
- Pair up the pages created while provisioning the site with the equivalent items in the source site by assigning the same variation group ID to both and copy the page content from source to target label using the content deployment and migration API
- Recursively provision all sites that exist below the variation top site in the source label to the target label and copy all pages in the pages library using the content deployment and migration API. If required adjust the page layout of the page based on the page layout configuration for the different labels
- Afterwards the new top site is configured as variation top site of the label and the hierarchy of the label will be marked as created
Note: Be aware that the pages in the target label will not be a one-to-one copy of the pages in the source label. Certain field and properties will not be copied as it has to be possible to have different values in source and target. Here is a list of the fields which are not overwritten when creating/updating a page variant:
Title, Description, StartDate, EndDate, Layout, Audience, Contact, LocalContactName, LocalContactEmail, LocalContactImage, PreviousSpawnSourcePageVersion, FieldId.DocumentId, FieldId.AverageRatings, FieldId.RatingsCount