This file contains 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
namespace XXXCUSTOM.Middleware | |
{ | |
using Microsoft.AspNetCore.Http; | |
using Sitecore.AspNet.RenderingEngine; | |
using Sitecore.LayoutService.Client.Response.Model; | |
using Sitecore.LayoutService.Client.Response.Model.Fields; | |
using System.Threading.Tasks; | |
public class RedirMiddleware | |
{ |
This file contains 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
using SharedSource.RedirectModule.Classes; | |
using SharedSource.RedirectModule.Helpers; | |
using Sitecore.Data; | |
using Sitecore.Data.Items; | |
using Sitecore.Links; | |
using Sitecore.Rules; | |
using System; | |
using System.Collections.Generic; | |
using System.Text.RegularExpressions; |
This file contains 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
if (HttpContext.Current?.Request?.Headers.AllKeys == null) | |
{ | |
return null; | |
} | |
var customCookie = HttpContext.Current?.Request?.Headers["XXX"]; | |
var result = ContactIdentificationManager.IdentifyAs(new KnownContactIdentifier("Salesforce.ContactId", customCookie)); | |
This file contains 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
SitecoreLayoutRequest sitecoreLayoutRequest = _requestMapper.Map(httpContext.Request); | |
string cookieValueFromContext = _httpContextAccessor.HttpContext.Request.Cookies["_XXXX_trk"]; | |
if (!string.IsNullOrEmpty(cookieValueFromContext)) | |
{ | |
sitecoreLayoutRequest.AddHeader("XXXX", new string[] { cookieValueFromContext }); | |
} |
This file contains 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
namespace XXXX.Controllers | |
{ | |
using Microsoft.AspNetCore.Mvc; | |
using Sitecore.AspNet.RenderingEngine; | |
using Sitecore.LayoutService.Client.Exceptions; | |
public class SitecoreController : Controller | |
{ | |
public IActionResult Index() | |
{ | |
var request = HttpContext.GetSitecoreRenderingContext(); |
This file contains 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
using Sitecore.Analytics; | |
using Sitecore.Analytics.XConnect.Facets; | |
using Sitecore.Diagnostics; | |
using Sitecore.Rules; | |
using Sitecore.Rules.Conditions; | |
using Sitecore.XConnect; | |
using Sitecore.Xdb.Configuration; | |
using System.Collections.Generic; | |
using System.Linq; |
This file contains 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
using System.Linq; | |
using System.Globalization; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json.Linq; | |
using System.Collections.Generic; | |
using Stylelabs.M.Base.Querying; | |
using Stylelabs.M.Base.Querying.Filters; | |
using Stylelabs.M.Sdk.Contracts.Querying; | |
This file contains 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
$rendering = Get-Item -Path "master:\sitecore\layout\Renderings/Feature\XXXX" | |
$items = Get-ChildItem -Path "master:\sitecore\content\home" -Recurse | |
foreach($item in $items) { | |
$renderingInstance = Get-Rendering -Item $_ -Rendering $rendering | |
if ($renderingInstance) { | |
Set-Rendering -Item $_ -Instance $renderingInstance -Parameter @{ | |
"Reset Caching Options" = "1" | |
} | |
Write-Host "Updated Item $($_.Paths.FullPath)" |
This file contains 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
$renderingPath = "/sitecore/layout/Renderings/Feature/MYRENDERINGPath" | |
$renderingItem = Get-Item -Database "master" -Path $renderingPath | New-Rendering -Placeholder "main" | |
# Find the item where to add the new rendering | |
$item = Get-Item -Path "master:\content\Home" | |
# Bingo! Add the rendering to the item | |
Add-Rendering -Item $item -PlaceHolder "main" -Instance $renderingItem -Parameter @{ "Reset Caching Options" = "1" } -FinalLayout |
This file contains 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
Import-Function -Name ConvertTo-Xlsx | |
[byte[]]$myPages = Get-ChildItem -Path "/sitecore/content/Home" -Recurse | Where-Object { $_.TemplateID -match "{xxxxxxxx-xxxx-xxxx}" }|Select-Object -Property Name,Id,TemplateName,ProviderPath, "Meta Robots"|ConvertTo-Xlsx | |
Out-Download -Name "report-$datetime.xlsx" -InputObject $myPages |
NewerOlder