Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
AdamNaj / Import.ps1
Created November 7, 2018 16:04
Wordpress XML (to SXA) import script (messy output)
$xmlPath = "$AppPath\sugcon.xml"
$pageTemplate = "Project/Community/Page"
$siteHome = "master:\content\Community\SUGCON\Home"
$sitepath = "master:\content\Community\SUGCON"
[string[]]$content = get-content $xmlPath
[xml]$xml = $content
$pages = $xml.rss.channel.item | %{ [PSCustomObject]@{
@AdamNaj
AdamNaj / Set-ItemFieldToExternalLink.ps1
Created October 26, 2015 20:47
Set item field to external url
@AdamNaj
AdamNaj / Clone Site.ps1
Created June 13, 2018 05:08
Modify SXA "Clone Site" script to be able to clone sites with Security set up on them.
# Open the following item:
# /sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Multisite/Content Editor/Context Menu/Clone Site
# inside the try{ } clause wrap its content with:
New-UsingBlock(New-Object -TypeName "Sitecore.SecurityModel.SecurityDisabler"){
# all code that was inside the try clause before - goes here
}
@AdamNaj
AdamNaj / Convert-EventsToSearchable.ps1
Created September 15, 2017 10:21
Better Events List Script - Convert SXA Events templates into searchable items
$tenantTemplatesPath = "master:\templates\Project\Showcase"
$sitePath = "master:\content\Showcase\int"
function Assert-FeatureTemplateInProject {
[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[String[]] $TenantTemplateFolder,
[parameter(Mandatory=$true)]
@AdamNaj
AdamNaj / Renderings.ps1
Created June 23, 2014 16:19
Rendering manipulation in PowerShell for Sitecore
$item = get-item master:\content\Demo\Int\Home
$device =Get-Device -Default
$contentDataSource = get-item master:\content\Demo\Int\Home\about-us\employee-stories\adam-najmanowicz
$ImageDataSource = get-item master:\content\Demo\Int\Data\Images\d56cf7e777a2496aa6489a7bffc03539
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Content
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main -Parameter @{FieldName ="Title"} -DataSource $contentDataSource
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Image
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main -DataSource $ImageDataSource
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Subtitle
@AdamNaj
AdamNaj / Add-ProjectSpecificComponentDatasource.ps1
Last active September 29, 2017 17:06
Create project specific datasource templates for your SXA tenant so you can extend them with custom fields - Promo on Showcase example
###### user settings start here
# Path to the tenant that you want to update
$tenantTemplatesPath = "master:\templates\Project\Showcase"
# Site that should be upgraded to the new template - ise asterisk to upgrade multiple sites.
$sitePath = "master:\content\Showcase\*"
# Path to the component for which you want to introduce your own data source
$componentPath = 'master:\layout\Renderings\Feature\Experience Accelerator\Page Content\Promo'
@AdamNaj
AdamNaj / Add-TagToPages.ps1
Created August 30, 2017 16:45
Add SXA Tags to all SXA Pages
$sitePath = "master:\content\Demo\Origin"
#get items but only those that are SXA pages
$pages = Get-ChildItem "$sitePath\Home" -Recurse -WithParent |
Where-Object { Test-BaseTemplate -Item $_ -Template "Foundation/Experience Accelerator/Multisite/Content/Page" }
#you can pipe it to further filtering here if you want to do it only for some pages
#get tag items that contain the word "Adam" in them
$tags = (@() + (Get-ChildItem "$sitePath\Data\Tags" -Recurse |
Where-Object { Test-BaseTemplate -Item $_ -Template "Feature/Experience Accelerator/Taxonomy/Datasource/Tag" } |
@AdamNaj
AdamNaj / Set-Layout.ps1
Created August 30, 2017 15:39
Set a layout for a device across multiple pages
# branch that should be replaced - change the path
$items = Get-ChildItem master:\content\home2 -WithParent
# layout I want to set on my items
$layout = Get-Item 'master:\layout\Layouts\Foundation\Experience Accelerator\MVC\MVC Layout'
# Device on which I want to set it
$device = Get-LayoutDevice "Mobile"
foreach($item in $items){
@AdamNaj
AdamNaj / CopyOrMove-Renderings.ps1
Last active August 29, 2017 20:55
Copy or Move renderings from one device to another (within Shared layout)
#branch that should be replaced - change the path
$items = Get-ChildItem master:\content\home2 -WithParent
#Provide the names for your devices from which and to which things should be copied
$fromDevice = Get-LayoutDevice "Default"
$toDevice = Get-LayoutDevice "Mobile"
# for Final layout renderings you need to add -FinalLayout switch to the Add/Remove-Rendering cmdlets
# and provide the -Language for which you want to perform the operation
@AdamNaj
AdamNaj / Test-RenderingUsage.ps1
Created June 5, 2017 15:08
What Items are using my rendering?!
Get-Item 'master:\layout\Renderings\Feature\Experience Accelerator\Media\Video' | Get-ItemReferrer | Show-ListView