次の小さなスクリプトがあります
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
using (new Sitecore.SecurityModel.SecurityDisabler())
{
foreach (Sitecore.Data.Items.Item child in item.Children)
{
foreach (ItemLink link in child.Links.GetAllLinks())
{
Item itm = link.GetTargetItem();
if (itm != null) {
Response.Write(link.TargetPath + " (" + itm.Paths.IsMediaItem + ", " + itm.ID + ")" + "<br/>");
} else
{
Response.Write("<span style='color:red;font-weight:bold;'>NULL ITEM ("+ link.TargetPath + ")</span><br/>");
}
}
if (item.Paths.ContentPath.Split("/".ToCharArray()).Length <= 10)
RecurseLinks(child, reset);
}
}
これは、指定された開始パスからすべてのアイテム (および子) をループし、アイテムで定義されているすべてのリンクを取得します。
リンクの一部は現在、リンク先のアイテム (メディアまたはコンテンツ アイテム) の ID ではなく、絶対パスで定義されているため、更新する必要があります。
上記のスクリプトでこれを達成するにはどうすればよいですか?