Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
# Create Package & Set Properties
$package = new-package "Test Pages & Components";
$package.Sources.Clear();
$package.Metadata.Author = "aseabridge";
$package.Metadata.Publisher = "Flux Digital";
$package.Metadata.Version = "1.0";
$package.Metadata.Readme = 'This package contains number of test pages and components';
Write-Host "Creating Test Pages & Components Package..."
@fluxdigital
fluxdigital / add-new-item-with-forced-id.ps1
Last active January 8, 2021 00:01
Add a New Item with an Specific ID
New-Item -Path "master:\content\home" -Name "Item With Forced ID" -ItemType "Sample/Sample Item" -ForceId "777f5e27-bbb2-462b-a3bc-8e170e84649d"
@fluxdigital
fluxdigital / add-captcha-to-wffm-forms.ps1
Last active October 9, 2020 16:35
adds a captcha to any form within a folder that doesn't have a captcha already
#add captcha to any form that doesn't have one already
$formsRootPath = "master:/sitecore/content/Wbsite1/forms/test"
$wffmFormTemplateId = "{FFB1DA32-2764-47DB-83B0-95B843546A7E}"
$wffmFieldTemplateId = "{C9E1BF85-800A-4247-A3A3-C3F5DFBFD6AA}"
$captchaFieldTemplateId = "{7FB270BE-FEFC-49C3-8CB4-947878C099E5}"
$captchaFieldName = "I'm not a Robot"
$captchFieldSortOrder = 1000
$updatedCount = 0
Write-Host "Getting List of Forms to add Captchas to from: $($formsRootPath)..."
@fluxdigital
fluxdigital / add experience editor button to rendering
Created August 20, 2020 00:27
add-experience-editor-button-to-rendering.ps1
#add button to custom experience editor button to all matching components
$componentsPath = Get-ChildItem -Path "/sitecore/layout/Renderings/Shared/Test"
$multiListFieldName = "Page Editor Buttons"
$buttonIdToAdd = "{26A25CDD-E49D-4846-BA07-17D85C6DA950}"
Write-Host "Getting Components..."
foreach($component in $componentsPath){
#check if there is no datasource
if($component.Fields["Datasource Location"].Value -ne ""){
@fluxdigital
fluxdigital / update-field-value-to-same-values-as-standard-value.ps1
Last active November 10, 2019 02:07
Updates a field value to the same value as the standard value but updates the field so it is no longer using the standard value
$templateIds =
'{565F2D63-1359-726C-AB77-F3DA34C90AD0}',
'{3465B346-3B37-8E40-AB70-31E17F4F38H4}',
'{78309E9F-49A6-91C9-9DC3-73F340CE6690}'
$global:usingStandardValues = 0
$global:notUsingStandardValues = 0
$global:updateContentTypeField = $false
$global:fieldName = "content type"
@fluxdigital
fluxdigital / Copy-Page-FinalLayout-To-Template.ps1
Last active September 5, 2019 23:12
Copies Final Layout Back To Page Template and optionally resets the page final renderings back to the page templates standard values
function Copy-Page-FinalLayout-To-Template([string]$pagePath,[switch]$ResetLayout){
#get the page item
$item = Get-Item -Path "master:$pagePath"
#get the final layout from the page
$finalLayoutField = New-Object -TypeName "Sitecore.Data.Fields.LayoutField" -ArgumentList $Item.Fields[[Sitecore.FieldIDs]::FinalLayoutField]
if ($finalLayoutField -eq $null) {
Write-Error "Couldn't find final layout on: $($Item.Name)"
}
@fluxdigital
fluxdigital / Create-Component-Datasource.ps1
Created August 14, 2019 22:31
Create component datasource based on component base path and template path and names
function Create-Component-Datasource([string]$componentBasePath, [string]$templateBasePath, [string]$componentFolderName, [string]$componentName, [string]$componentFolderTemplateName, [string]$componentTemplateName){
###create component folder item###
Write-Host "Creating component folder: $($componentBasePath)/$($componentFolderName) with template: $($templateBasePath)/$($componentFolderTemplateName)"
$componentFolderItem = New-Item -Path $componentBasePath -Name $componentFolderName -ItemType "$($templateBasePath)/$($componentFolderTemplateName)"
###create component item###
Write-Host "Creating component: $($componentBasePath)/$($componentFolderItem.Name)/$($componentName) with template: $($templateBasePath)/$($componentTemplateName)"
$componentItem = New-Item -Path "$($componentBasePath)/$($componentFolderItem.Name)" -Name $componentName -ItemType "$($templateBasePath)/$($componentTemplateName)"
@fluxdigital
fluxdigital / Scaffold-View-Rendering.ps1
Last active August 14, 2019 21:09
creates a view rendering at the specified location and adds datasource, data template and cache settings.
function Scaffold-View-Rendering([string]$renderingName, [string]$renderingPath, [string]$viewPath, [string]$dataSourcePath, [string]$dataSourceTemplate){
###create rendering###
$renderingItem = New-Item -Path $renderingPath -Name $renderingName -ItemType "/sitecore/templates/System/Layout/Renderings/View rendering"
$renderingItem.Editing.BeginEdit();
#set path
$renderingItem["Path"] = $viewPath;
#set default rendering icon
@fluxdigital
fluxdigital / Scaffold-Component-And-Folder.ps1
Last active August 14, 2019 21:10
Creates a component and folder and set insert options for standard values on the folder
function Scaffold-Component-And-Folder([string]$componentName, [string]$componentPath){
###create component template###
$componentItem = New-Item -Path $componentPath -Name $componentName -ItemType "/sitecore/templates/System/Templates/Template"
$componentItem.Editing.BeginEdit()
#set default component icon
$componentItem["__Icon"] = "/~/icon/software/32x32/component.png";
$componentItem.Editing.EndEdit()
Write-Host "Component Created: " $componentItem.Name
<configuration name="Shared" description="Shared Unicorn Config">
<predicate>
<include name="SharedPageLayouts" database="master" path="/sitecore/layout/Layouts/Shared" />
<include name="SharedTemplates" database="master" path="/sitecore/templates/Shared" />
<!--exclude the Navigation 'Home Link' field using Field Transforms-->
<include name="SharedNavigation" database="master" path="/sitecore/content/Shared/Navigation" fieldTransforms="-Home Link">
</predicate>
<dataProviderConfiguration enableTransparentSync="false" />