Skip to content

Instantly share code, notes, and snippets.

@BillCacy
BillCacy / BlueGreenSolrHelper.psm1
Last active July 27, 2021 13:57
Solr script to handle the CDCR replication switching during a Blue/Green deployment.
using module ".\BlueGreenSolrSettings.psm1"
$ErrorActionPreference = "Stop"
<#
.SYNOPSIS
Pushes the specified config and related pieces to the SolrCloud Zookeepers.
.PARAMETER solrPath
Path on the machine to the Solr installation.
EX: C:\solr\solr-6.2.1
@BillCacy
BillCacy / BlueGreenSolrSettingsMap.psm1
Created October 10, 2018 04:20
Solr settings mapping from Octopus variables.
using module ".\BlueGreenSolrSettings.psm1"
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
<#
.SYNOPSIS
Creates a BlueGreenSolrSettings object with property values defined by Octopus variables.
.PARAMETER Settings
An string dictionary passed in from Octopus deploy containing the variables used in
the defined deployment process.
@BillCacy
BillCacy / BlueGreenSolrSettings.psm1
Created October 10, 2018 04:19
Solr settings object for Blue/Green deployment.
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
<#
.SYNOPSIS
Classes and properties utilized by the scripts to update SolrCloud in a blue/green environment
#>
class OctopusMachineSettings
{
@BillCacy
BillCacy / UpdateFieldValues.ps1
Created June 9, 2016 19:03
Sitecore Powershell - Update field values in all rich text items
$root = gi master:// -id "{0C3015B8-77AD-44DC-9633-2AD76489483A}"
$items = $root | ls -r | %{$item = $_; $_.Fields | ?{$_.TypeKey -eq "rich text"} }
#$items.Count
foreach($i in $items){
if($temp){
clear-variable("temp")
}
if($replaced){
clear-variable("replaced")
}
@BillCacy
BillCacy / AddLeftNavAndSocialMedia.ps1
Created June 9, 2016 19:02
Sitecore Powershell script to add renderings to Product Pages
$root = gi master:// -id "{076927BD-FFD2-4658-B522-D836C045CF7D}"
$items = $root | ls -r | ?{$_.TemplateName -eq "ProductPage"}
$leftNavRendering = gi master:\layout\Renderings\Site\Components\LeftNav | New-Rendering -Placeholder "contentMain"
$socialMediaRendering = gi master:\layout\Renderings\Site\Components\SocialMedia\SocialMediaBar | New-Rendering -Placeholder "contentMain"
foreach($i in $items){
if($leftNavDsPath){
clear-variable("leftNavDsPath")
}
if($leftNavDs){
@BillCacy
BillCacy / SearchResults.cshtml
Created September 17, 2015 22:47
This is the view used to render the search results.
@model YOURNAMESPACE.ViewModels.Common.Components.Search.SearchResultsViewModel
<div class="container-fluid width-90">
<div class="row">
<h1>Search results for &ldquo;@Model.SearchTerm&rdquo;</h1>
@if (Model.SearchResults != null && Model.SearchResults.Any())
{
foreach (var result in Model.SearchResults)
{
@BillCacy
BillCacy / SearchResultsViewModel.cs
Created September 17, 2015 22:45
View model used for the search results
using System.Collections.Generic;
namespace YOURNAMESPACE.ViewModels.Common.Components.Search
{
public class SearchResultsViewModel
{
public string ViewPath { get { return Constants.Components.SearchResultsViewPath; } }
public IEnumerable<SiteSearchResult> SearchResults { get; set; }
public int TotalPageCount { get; set; }
public int TotalResults { get; set; }
@BillCacy
BillCacy / SearchResultsIndexAgent.cs
Created September 17, 2015 22:43
These are the methods used by the controller to handle the actual searching and mapping of results to the view model.
public void Search(string term, string page)
{
if (string.IsNullOrEmpty(term))
{
ViewModel.SearchTerm = "No search term entered";
return;
}
ViewModel.SearchTerm = term;
var sitecoreService = new SitecoreService(Sitecore.Context.Database);
@BillCacy
BillCacy / PageBaseSearchResult.cs
Created September 17, 2015 22:27
SearchResult implementation for use with the search api.
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.SearchTypes;
namespace YOURNAMESPACE.ConcreteModels
{
public class PageBaseSearchResult : SearchResultItem
{
[IndexField("pagecontentfield")]
public string PageContentField{ get; set; }
}
@BillCacy
BillCacy / SiteSearchResult.cs
Created September 17, 2015 22:24
Result class for mapping from the search interface
namespace YOURNAMESPACE.Search
{
public class SiteSearchResult
{
public string Title { get;set; }
public string PageLinkUrl { get; set; }
public string Content { get; set; }
}
}