有谁知道如何获得所有受保护的物品(以及之后没有保护的物品)列表?
我在谷歌上搜索过,但没有找到任何相关结果。
提前感谢
这就是我目前所拥有的..。
var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath);
foreach (Item item in homeItem.Children)
{
if (item.Locking.IsLocked())
{
//to do
}
}
不幸的是,如果项目受到保护或不受保护,item.Locking.IsLocked将不会返回。
发布于 2014-01-20 03:49:05
当您按下“保护”或“取消保护”项时,将调用此命令:
item:togglereadonly
这是保护或取消保护项目的方法的一部分:
public override void Execute(CommandContext context)
{
if (context.Items.Length != 1)
return;
Item obj = context.Items[0];
obj.Editing.BeginEdit();
obj.Appearance.ReadOnly = !obj.Appearance.ReadOnly;
obj.Editing.EndEdit();
Log.Audit((object) this, "Toggle read only: {0}, value: {1}", AuditFormatter.FormatItem(obj), MainUtil.BoolToString(obj.Appearance.ReadOnly));
}
发布于 2014-01-20 03:45:50
找到解决办法
var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath);
foreach (Item item in homeItem.Children)
{
if (item.Appearance.ReadOnly)
{
//stuff here
}
}
干杯
https://stackoverflow.com/questions/21225103
复制相似问题