-
-
Save strezag/5e98910f887e0d4224f12352b5b9de24 to your computer and use it in GitHub Desktop.
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-LinkFieldUrl { | |
[CmdletBinding()] | |
param( | |
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] | |
[ValidateNotNullOrEmpty()] | |
[Sitecore.Data.Items.Item]$Item | |
) | |
# Regular expression to extract the URL | |
$regex = '<link\s+url="([^"]+)"' | |
$linkFieldValue = $Item.Fields["My Link Field"].Value; | |
if ($linkFieldValue -ne "") { | |
if ($linkFieldValue -match $regex) { | |
$urlValue = $matches[1] | |
return $urlValue | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment