Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
@fluxdigital
fluxdigital / BlogPostSearchResultsController.cs
Last active September 16, 2022 00:01
Blog Post Search Results Controller
public class BlogPostSearchResultsController : SitecoreController
{
private readonly ISearchService _blogPostSearchService;
public BlogPostSearchResultsController(ISearchService BlogPostSearchService)
{
_blogPostSearchService = BlogPostSearchService;
}
public ActionResult Results()
@fluxdigital
fluxdigital / Blog Post Search Results View
Created September 16, 2022 00:00
BlogPostSearchResults.cshtml
@using Glass.Mapper.Sc.Web.Mvc
@using FluxDigital.Feature.Search.Models
@using PagedList.Mvc
@using Sitecore.Configuration
@model BlogPostSearchResultsModel
<div class="wrapper">
<form class="search" action="" method="GET">
<div class="search-box">
@fluxdigital
fluxdigital / Feature.BlogPostSearch.Index.Web.config
Last active September 16, 2022 00:34
Config for Blog Post index
<?xml version="1.0" encoding="utf-8" ?>
<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:role="http://www.sitecore.net/xmlconfig/role/"
xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore role:require="Standalone or ContentManagement or ContentDelivery" search:require="solr">
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="sc93_blogs_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
<?xml version="1.0" encoding="utf-8" ?>
<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:role="http://www.sitecore.net/xmlconfig/role/"
xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore role:require="Standalone or ContentManagement or ContentDelivery" search:require="solr">
<contentSearch>
<indexConfigurations>
<blogPostSearchIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">
@fluxdigital
fluxdigital / Create-Item-ChatGPT.ps1
Created December 16, 2022 00:10
Create Sitecore Item - ChatGPT
# Set the necessary parameters for the new item
$itemName = "My New Item"
$itemTemplate = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}" #Sample Item
$parentItemPath = "/sitecore/content/Home"
# Create the new item
$newItem = New-Item -ItemType $itemTemplate -Name $itemName -Path $parentItemPath
# Set the new item's field values
$newItem.Editing.BeginEdit()
@fluxdigital
fluxdigital / Unlock-Items-ChatGPT.ps1
Created December 16, 2022 00:21
Unlock Items for User - ChatGPT
# Set the username of the user whose locked items you want to unlock
$username = "admin"
# Get a list of all items locked by the specified user
$lockedItems = Get-ChildItem -Path "master:\" -Recurse | Where-Object {
$_.Locking.IsLocked -and $_.Locking.LockedBy -eq $username
}
# Unlock all items in the list
foreach ($item in $lockedItems) {
@fluxdigital
fluxdigital / params-in-dependencyinjection.config
Last active March 16, 2023 23:40
Pass Params in Dependency Injection
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<services>
<configurator type="FluxiDigtal.Foundation.DependencyInjection.MvcControllerServicesConfigurator, FluxiDigtal.Foundation.DependencyInjection">
<!--turn on option on CD-->
<param desc="useMyCustomCache" role:require="ContentDelivery">true</param>
</configurator>
</services>
</sitecore>
@fluxdigital
fluxdigital / Di-ServicesConfigurator.config
Created March 16, 2023 22:34
DI ServicesConfigurator config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator type="FluxiDigtal.Foundation.DependencyInjection.ServicesConfigurator, FluxiDigtal.Foundation.DependencyInjection">
</configurator>
</services>
</sitecore>
</configuration>
@fluxdigital
fluxdigital / ConvertSitecorePublishFileToCLIJson.ps1
Last active October 29, 2023 19:40
Creates an Sitecore CLI JSON file from an Sitecore Package File
#*** converts an Publish.xml file to the new Sitecore CLI Json format ***
#helper functions
function CheckNamePart($namePart){
$namePart = $namePart.Replace(' ','')
$namePart = $namePart.Replace('{','')
$namePart = $namePart.Replace('}','')
return $namePart
}
@fluxdigital
fluxdigital / IAR-Content-Editor-Warning.ps1
Created November 12, 2023 21:36
Adds IAR Check and message to Content Editor
### Adds IAR Check and message to Content Editor ###
#IARs method for GetItemLocations() are only available in 10.2 an above - so return if Sitecore 9 -> 10.1
$sitecoreversion = [Sitecore.Configuration.About]::Version
if ($sitecoreversion.StartsWith('9') -or $sitecoreversion.StartsWith('10.0') -or $sitecoreversion.StartsWith('10.1'))
{
#Sorry this is only for Sitecore 10.2+ and XMCloud
exit
}