Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
@fluxdigital
fluxdigital / Swap-DataSource-Function.ps1
Created December 17, 2018 23:28
Update a Rendering Datasource
function Swap-DataSource ($item, $renderingToUpdate, $renderingDataSourceIdToAdd, $useFinalLayout) {
$renderingItem = Get-Item -Path $renderingToUpdate.ItemID
Write-Host "Swaping Rendering Datasource: $($renderingId.UniqueID) - '$($renderingItem.Name)' to: $($renderingDataSourceIdToAdd) for Item: $($item.Name)"
$renderingToUpdate.Datasource = $renderingDataSourceToAdd
Set-Rendering -Item $item -Instance $renderingToUpdate -FinalLayout:$useFinalLayout
}
Param(
$solrVersion = "7.2.1",
$installFolder = "C:\solr",
$solrPort = "8983",
$solrHost = "solr-910",
$solrSSL = $true,
$nssmVersion = "2.24",
$JREVersion = "9.0.1"
)
@fluxdigital
fluxdigital / fix-azure-index-name-functions.cs
Created May 14, 2019 21:00
Provides Functions to allow fix azure index bug with index rebuild
protected void SwitchPrimaryIndex(string indexName, string machineName, bool isCd)
{
//get key
var indexKey = GetIndexKey(indexName, machineName, isCd);
//get current primary key name
var currentPrimaryIndexName = database.Properties[indexKey];
//default to this as new index name
var newPrimaryIndexName = currentPrimaryIndexName;
@fluxdigital
fluxdigital / unicorn-fieldfilter-example.config
Last active May 31, 2019 11:25
Unicorn fieldFilter example
<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" />
<include name="SharedNavigation" database="master" path="/sitecore/content/Shared/Navigation" fieldTransforms="-Home Link">
</predicate>
<!--exclude the Navigation 'Home Link' field-->
<fieldFilter type="Rainbow.Filtering.ConfigurationFieldFilter, Rainbow">
<exclude fieldID="{A2B16B7789-7A0B-4FE6-94FD-66A9E6F8BD08}" note="'Home Link' field on the Navigation template" key="HomeLink" />
<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" />
@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
@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 / 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 / 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 / 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"