This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
### Creates Draft Sites for all existing Sites - for use on the CM Instance ### | |
.Description | |
For each site -> Duplicates the existing Site Grouping item and adds 'DRAFT' to the name. | |
Sets the environment to 'Draft' and database to 'master' also sets the target hostname to the current CM instance Url. | |
#> | |
$rootItem = Get-Item -Path "/sitecore/content" | |
$sxaSites = Get-ChildItem -Path "/sitecore/content/Sites" | |
$successCount = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
### Context Menu script to creates a single SXA Draft Site - for use on the CM Instance ### | |
.Description | |
Should be created in the Content Menu section, e.g: /sitecore/system/Modules/PowerShell/Script Library/{YOUR SCRIPT LIBRARY}/Content Editor/Context Menu | |
Duplicates the existing Site Grouping item and adds 'DRAFT' to the name. | |
Sets the environment to 'Draft' and database to 'master' also sets the target hostname to the current CM instance Url. | |
Moves the new Draft site to the top of the list so it is loaded before the non-Draft site. | |
#> | |
Import-Function -Name "Get-CmUrl" | |
Import-Function -Name "Move-Preview-Site-To-Top" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
### Moves all SXA Draft Sites to Top of list so they load on the CM before the non-Draft sites ### | |
.Description | |
Before running this script open the SXA Site Manager from the Powershell Toolbox to ensure all sites are up to date. | |
All Draft sites will be moved to the top of this field: "/sitecore/system/Settings/Foundation/Experience Accelerator/Multisite/Management/Sites" | |
#> | |
$sxaSitesList = Get-Item -Path "master:/sitecore/system/Settings/Foundation/Experience Accelerator/Multisite/Management/Sites" | |
$orderField = $sxaSitesList.Fields["Order"].Value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
### Displays a 'Draft Site' message in Experience Editor ### | |
.Description | |
The $text variable below should be edited as required. | |
#> | |
$title = "Displaying Draft Site" | |
$text = "You are viewing the draft (Master DB) version of the site." | |
$icon = @{$true="Office/32x32/information.png";$false="Applications/16x16/warning.png"}[$SitecoreVersion.Major -gt 7] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
### Removes all existing SXA 'Draft' Sites ### | |
.Description | |
Finds all SXA Draft sites and deletes them. | |
#> | |
$sxaSites = Get-ChildItem -Path "/sitecore/content/Sites" | |
$successCount = 0 | |
$failCount = 0 | |
$siteGroupingPath = "Settings/Site Grouping" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Function used to move preview site to the top of the list | |
#> | |
function Move-Preview-Site-To-Top($newSiteId){ | |
$sxaSitesList = Get-Item -Path "master:/sitecore/system/Settings/Foundation/Experience Accelerator/Multisite/Management/Sites" | |
$orderValuesCurrent = $sxaSitesList.Fields["Order"].Value; | |
write-host "New Site ID: $($newSiteId)" | |
write-host "Current Order Values: $($orderValuesCurrent)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Function used to find the CM Url | |
#> | |
function Get-CmUrl($item){ | |
$site = [Sitecore.Sites.SiteContext]::GetSite("website") | |
New-UsingBlock(New-Object -TypeName "Sitecore.Sites.SiteContextSwitcher" -ArgumentList $site) { | |
$urlOptions = [Sitecore.Links.LinkManager]::GetDefaultUrlOptions() | |
$urlOptions.AlwaysIncludeServerUrl = $True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int IndexContent() | |
{ | |
var indexedCount = 0; | |
using (new SecurityDisabler()) | |
{ | |
try | |
{ | |
//get the blog posts from Sitecore | |
var blogPostsRootPath = _master.GetItem(Settings.GetSetting("BlogPostsRootPath")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BlogPostSearchResultsModel GetResults(BlogPostSearchResultsModel blogPostSearchResultsModel, string searchTerm, int resultsPerPage, int currentPage) | |
{ | |
using (new SecurityDisabler()) | |
{ | |
try | |
{ | |
var solrCharsToAllow = "()-+*./' "; | |
var solrCharsToEscape = "(,),||,!,[,],^,~,?,:,-,+,\""; //split on comma | |
var safeSearchTerm = searchTerm.Trim().RemoveSpecialCharacters(solrCharsToAllow); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogPostSearchIndexJob : IJob | |
{ | |
private readonly ISearchService _blogPostSearchService; | |
private readonly ILogService _logService; | |
public BlogPostSearchIndexJob() : | |
this(ServiceLocator.ServiceProvider.GetService<ISearchService>(), | |
ServiceLocator.ServiceProvider.GetService<ILogService>(), | |
{ |