Add modules to Site and Tenant scaffolding

Abstract

Extend SXA by adding scaffolded items.

Scaffolding lets you add modules to sites and tenants. SXA modules are stored in the Feature or Foundation folder:

  • /sitecore/System/Settings/Foundation/Experience Accelerator/

  • /sitecore/System/Settings/Feature/Experience Accelerator/

To define your new module, you must add the Site Setup, Tenant Setup, or Grid Setup item to the module and add action types from the Scaffolding folder (sitecore/Templates/Foundation/Experience Accelerator/Scaffolding/).

This topic describes how to:

To add your own module scaffolding definition:

  1. Navigate to /sitecore/System/Settings/Foundation/ or /sitecore/System/Settings/Feature/ and add a folder.

  2. Right-click the new folder, and click Insert from template.

  3. In the Insert from template dialog box, navigate to sitecore/Templates/Foundation/Experience Accelerator/Scaffolding/Roots and, depending on the type of module that you want to add, click Grid Setup, Site Setup, or Tenant Setup, and then click Insert.

    D534555D2F65409580D3A43CF1C24D6D.png
  4. In the data sections, depending on the type of feature that you want to install, fill in the following fields:

    Setup

    Field

    Descriptions

    Site Setup

    Name

    The name of the site module as you want it to display in the site creation wizard.

    Dependencies

    Specify the order in which the modules are installed.

    Include by default

    Select to enable the module by default in the site creation wizard.

    Is system feature

    Select to install the module automatically. In this case, the module does not appear in the dialog box.

    Tenant Setup

    Name

    The name of the tenant module as you want it to display in the tenant creation wizard.

    Include by default

    Select to enable the module by default in the tenant creation wizard.

    Is system feature

    Select to install the module automatically. In this case, the module does not appear in the tenant creation wizard.

    Grid Setup

    Name

    The name of the grid system as you want it to display in the site creation wizard.

    Dependencies

    Specify the order in which the modules are installed.

    Grid Definition

    Refers to the Grid Definition item. For example, for the Foundation grid system: Settings/Feature/Experience Accelerator/Foundation/Foundation

You can use various action types to define modules. You can add items, edit the template, and execute PowerShell scripts. The available actions are stored in the Actions folder (sitecore/Templates/Foundation/Experience Accelerator/Scaffolding/Actions):

15FF8E0E441B4F6396294FDE50C9523F.png

To add a scaffolding action:

  • Navigate to your new module and right-click the setup item that you added for your new module. For example, right-click the Site Setup item and insert the Add Site Item action.

    7CE6802867CA4624B663376868C1955B.png

The following actions are available:

Action type

Field

Description

Add Tenant Item

Location

Adds the new item under the tenant.

Template

Template used to create the new tenant item.

Name

Name of the item.

Fields

Field/value mapping to set the fields of the new item after creation.

Edit Tenant Template

Template

Select the template to copy into tenant templates. The template is edited according to the defined settings.

Type of action

Select the action type.

Base templates or insert options templates

Select items to use as an argument for the action selected in the previous field.

Execute Tenant Script

Script

Select the PowerShell script to execute. You can use scaffolding scripts to automate parts of the site/tenant creation process. For example:

function Invoke-ModuleScriptBody {
[CmdletBinding()]
    param(
        # Depending on context could be a Tenant or Site item
    [Parameter(Mandatory=$true, Position=0 )]
[Item]$Root,
[Parameter(Mandatory=$true, Position=1 )]        
        [Item[]]$TenantTemplates                
    )
begin {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - Begin"
}
process {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - Process"
        # Script body
        # Put your custom logic here
}
end {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - End"
}
}

Add Site Item

Location

Adds the new item under the site.

Template

Template used to create a new site item.

Name

Name of the new site item.

Fields

Field/value mapping to set the fields of the new item after creation.

Edit Site Item

Template

Edits Site items by adding additional insert options.

Type of action

Select the action type.

Insert options

Define the insert options for the item.

Execute Site Script

Script

Select the PowerShell script to execute. You can use scaffolding scripts to automate parts of the site/tenant creation process. For example:

function Invoke-ModuleScriptBody {
[CmdletBinding()]
    param(
        # Depending on context could be a Tenant or Site item
    [Parameter(Mandatory=$true, Position=0 )]
[Item]$Root,
[Parameter(Mandatory=$true, Position=1 )]        
        [Item[]]$TenantTemplates                
    )
begin {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - Begin"
}
process {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - Process"
        # Script body
        # Put your custom logic here
}
end {
Write-Verbose "Cmdlet Invoke-ModuleScriptBody - End"
}
}

Edit Editing Theme

Base Themes

List of base themes to add to an editing theme instance.

Edit Site Theme

Base Themes

List of base themes to add to an editing theme instance.

Post Setup Step

Script

Select the PowerShell script to execute. You can use scaffolding scripts to execute actions once the site is created.

function Invoke-Step {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0 )]
        [Sitecore.XA.Foundation.Scaffolding.Models.CreateNewSiteModel]$Model
    )
    begin {
        Write-Verbose "Cmdlet Invoke-Validation - Begin"
    }
    process {
        Write-Verbose "Cmdlet Invoke-Validation - Process"
    }
    end {
        Write-Verbose "Cmdlet Invoke-Validation - End"
    }
}

Input Validation Step

Script

Select the PowerShell script to execute. You can use scaffolding scripts to validate the model before the site is created. If the result returned by any of validation scripts is false, the New Site dialog box will display again so that you can correct some of the previously selected values.

function Invoke-Validation {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0 )]
        [Sitecore.XA.Foundation.Scaffolding.Models.CreateNewSiteModel]$Model
    )
    begin {
        Write-Verbose "Cmdlet Invoke-Validation - Begin"
    }
    process {
        Write-Verbose "Cmdlet Invoke-Validation - Process"    
        # Return $true or $false as a result of validation
        $true
    }
    end {
        Write-Verbose "Cmdlet Invoke-Validation - End"
    }

Post Setup Step

Script

Select the PowerShell script to execute. You can use scaffolding scripts to execute actions once tenant is created.

function Invoke-Step {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0 )]
        [Sitecore.XA.Foundation.Scaffolding.Models.CreateNewTenantModel]$Model
    )
    begin {
        Write-Verbose "Cmdlet Invoke-Validation - Begin"
    }
    process {
        Write-Verbose "Cmdlet Invoke-Validation - Process"
    }
    end {
        Write-Verbose "Cmdlet Invoke-Validation - End"
    }
}

Input Validation Step

Script

Select the PowerShell script to execute. You can use scaffolding scripts to validate model before the tenant is created. If the result returned by any of validation scripts is false, the New Tenant dialog box will display again so that you can correct some of the previously selected values.

function Invoke-Validation {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0 )]
        [Sitecore.XA.Foundation.Scaffolding.Models.CreateNewTenantModel]$Model
    )
    begin {
        Write-Verbose "Cmdlet Invoke-Validation - Begin"
    }
    process {
        Write-Verbose "Cmdlet Invoke-Validation - Process"
        # Return $true or $false as a result of validation
        $true
    }
    end {
        Write-Verbose "Cmdlet Invoke-Validation - End"
    }
}