Created
February 13, 2019 21:34
-
-
Save michaellwest/1f032892fb6c31864d43016c0b65c7a8 to your computer and use it in GitHub Desktop.
Generate an item url given an item and the sitecontext using Sitecore PowerShell Extensions.
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
function Get-ItemUrl { | |
param( | |
[item]$Item, | |
[Sitecore.Sites.SiteContext]$SiteContext | |
) | |
$result = New-UsingBlock(New-Object Sitecore.Sites.SiteContextSwitcher $siteContext) { | |
New-UsingBlock(New-Object Sitecore.Data.DatabaseSwitcher $item.Database) { | |
[Sitecore.Links.LinkManager]::GetItemUrl($item) | |
} | |
} | |
$result[0][0] | |
} | |
$siteContext = [Sitecore.Sites.SiteContext]::GetSite("website") | |
$item = Get-Item -Path "master:/content/home" | |
Get-ItemUrl -SiteContext $siteContext -Item $item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We just want to break to Read :
ChallengeResponseUrl = $item.Fields["ChallengeResponseUrl"];
This shoud Rerturn : "/MC/Home/ChallengeErrorPage"
ChallengeResponseUrl Data Type is General Link Type