Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
@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" />
@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;
Param(
$solrVersion = "7.2.1",
$installFolder = "C:\solr",
$solrPort = "8983",
$solrHost = "solr-910",
$solrSSL = $true,
$nssmVersion = "2.24",
$JREVersion = "9.0.1"
)
@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
}
@fluxdigital
fluxdigital / Swap-Rendering-Function.ps1
Created December 17, 2018 23:15
Swaps one rendering for another and optionally swaps out the datasource too
function Swap-Rendering ($item, $renderingToSwapOut, $placeholder, $renderingIdToAdd, $renderingDataSourceIdToAdd, $useFinalLayout) {
$renderingItem = Get-Item -Path $renderingToSwapOut.ItemID
Write-Host "Swaping Rendering: $($renderingToSwapOut.UniqueID) - '$($renderingItem.Name)' in Placeholder: $($placeholder) to: $($renderingIdToAdd) - '$($renderingToAdd.Name)' for Item: $($item.Name)"
$renderingToSwapOut.ItemID = $renderingIdToAdd
if($renderingDataSourceToAdd){
$renderingToSwapOut.Datasource = $renderingDataSourceToAdd
}
Set-Rendering -Item $item -Instance $renderingToSwapOut -FinalLayout:$useFinalLayout
}
@fluxdigital
fluxdigital / CustomDropDownListField.cs
Created November 28, 2018 14:35
WFFM custom drop down field (used in MVC)
public class CustomDropDownListField : DropListField
{
public CustomDropDownListField()
{
//initalise services here
}
private string InitialSelection { get; set; }
public override void Initialize()
public class CustomDropDownList : DropList
{
private static readonly string BaseCssClassName = "scfCustomlistBorder";
[ParameterName("emptychoicetext")]
[VisualCategory("Custom")]
[VisualProperty("Empty Choice Text:")]
public string EmptyChoiceText { get; set; }
[ParameterName("showemptychoice")]
@fluxdigital
fluxdigital / Swap-Remove-Page-Renderings.ps1
Last active December 17, 2018 23:37
SPE script to swaps one rendering for another and also deletes an rendering if required and updates datasources
$rootItem = Get-Item -Path "/sitecore/templates/Site1/Pages" #update to the path with your page templates
$deviceLayout = Get-LayoutDevice "Default" #update to device layout you wish to target
$templateMode = $True #set to False to update pages instead of templates (usually you will want to update template standard values)
$useFinalLayout = $False #set to True to use FinalRenderings instead of Renderings field
$checkForLayout = $False #set to True to skip items with no layout (use only for updating pages and not templates)
$updateDataSourcesOnly = $False #set to True to only update datasources and not swap or delete renderings
$reportMode = $False #set to True to just output info on renderings to be swapped/deleted/updated
$modeType = ""
$placeholder = "main" #update to use the placeholder your renderings exist in
$renderingIdToSwap = "{15BCE4DA-4F3C-42CA-9D4D-D46D572C7A8F}" #update to the rendering id you wish to swap out
@fluxdigital
fluxdigital / TcPostBase.cs
Created November 18, 2018 20:34
Base Telligent Community Post
public class TcPostBase
{
public string Id { get; set; }
public string ContentId { get; set; }
public string ContentTypeId { get; set; }
public string Url { get; set; }
public string Excerpt { get; set; }
public string Body { get; set; }
public string GroupId { get; set; }
public string IsFeatured { get; set; }
@fluxdigital
fluxdigital / TcBlogPost.cs
Created November 18, 2018 20:32
Telligent Community Blog Post
public class TcBlogPost : TcPostBase
{
public string Slug { get; set; }
public string Title { get; set; }
public string TitleUrl { get; set; }
public string PublishedDate { get; set; }
public string ExcerptSize { get; set; }
public string UsePostSummary { get; set; }
public string GeneratePostSummary { get; set; }
public string BlogId { get; set; }