ive currently got a powershell script in sitecore which goes through the Home directory and changes the target value for all general links to "Active browser"
What i would now like to do is also change the target values for all internal links in a link list.
Current script:
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
# Get items
$root = Get-Item -Path "master:/sitecore/content/SiteName"
# Get its descendents
$allItems = @( ($root.Axes.GetDescendants() | Initialize-Item))
# Get all
$allItems = @($root) + @(($root.Axes.GetDescendants() | Initialize-Item))
$allItems | ForEach-Object {
# Get the items
$currentItem = $_
# Get item fields and create loop
$currentItem.Fields | ForEach-Object {
#Check the field type
if ($_.type -eq "Linklist")
{
[Sitecore.Data.Fields.LinkField]$linkField = $currentItem.Fields[$_.name]
# Update target for Internal Links
if ($linkField.Linktype -eq 'internal')
{
$currentItem.Editing.BeginEdit()
$linkField.target = ""
$currentItem.Editing.EndEdit()
}
if ($_.type -eq "General Link")
{
[Sitecore.Data.Fields.LinkField]$linkField = $currentItem.Fields[$_.name]
# Update target for Internal Links
if ($linkField.Linktype -eq 'internal')
{
$currentItem.Editing.BeginEdit()
$linkField.target = ""
$currentItem.Editing.EndEdit()
}
}
}
}
}
Can anyone help? thanks!!