最快的方法是使用Sitecore Powershell模塊來設置所有項目的值。喜歡的東西:
cd 'master:/sitecore/content'
Get-ChildItem -Recurse . | Where-Object { $_.TemplateName -match "{template name}" -and $_.Fields["Title"] -ne $null } | ForEach-Object {
$_.Editing.BeginEdit()
$_.Fields["Title"].Value = "{new value}";
$_.Editing.EndEdit()
""
}
如果你不想使用Sitecore的PowerShell中,你可以使用C#編寫,通過樹循環遞歸函數。
例子:
private void UpdateAllFieldsRecursively(Item parentItem, string templateName, string fieldName, string newValue)
{
if (parentItem != null)
{
using (new SecurityDisabler())
{
foreach (Item childItem in parentItem.Children)
{
if (childItem.Fields[fieldName] != null && childItem.TemplateName == templateName)
{
using (new EditContext(childItem))
{
childItem[fieldName] = newValue;
}
}
if (childItem.HasChildren)
{
UpdateAllFieldsRecursively(childItem, templateName, fieldName, newValue);
}
}
}
}
}
在那裏你可以調用函數像這樣:
const string parentNode = "/sitecore/content";
var database = Sitecore.Context.Database;
var parentItem = database.GetItem(parentNode);
UpdateAllFieldsRecursively(parentItem, "{template name}", "Title", "{new value}");
我建議煉你的問題。你想對頁面標題做什麼?你想更新它們在開始/結束時添加一個特定的單詞嗎?我無法想象你想讓所有頁面擁有相同的頁面標題。但答案可能是一些使用Sitecore Powershell Extensions(SPE)的腳本。 –
我正在投票結束這個問題,因爲它涉及到最終用戶功能,因此不是特定的編程/編程工具--OP要求提供沒有編程元素的解決方案。 –