2012-04-17 93 views
1

如何以編程方式「重置」項目的佈局?這可以通過Sitecore客戶端從「演示文稿」選項卡進行。我無法在任何地方找到這樣的例子。Sitecore重置項目佈局

謝謝

回答

7

這是一個非常基本的方式來做你想問的問題。

Item item; // your item here... Sitecore.Context.Item perhaps? 

using (new Sitecore.SecurityModel.SecurityDisabler()) 
{ 
    if (!string.IsNullOrEmpty(item["__renderings"])) 
    { 
     using (new Sitecore.Data.Items.EditContext(item)) 
     { 
      item.Fields["__renderings"].Reset(); 
     }   
    } 
} 
+0

肖恩,你的意思是'__renderings'而不是? – 2012-04-17 16:55:32

+0

我做過馬克。我已經更新了答案。謝謝。 – 2012-04-17 19:14:54