本文整理汇总了C#中IItem.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# IItem.MoveTo方法的具体用法?C# IItem.MoveTo怎么用?C# IItem.MoveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IItem
的用法示例。
在下文中一共展示了IItem.MoveTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyItemCallback
public void CopyItemCallback(IItem sourceItem, IItem destinationParentItem, IItem destinationItem)
{
if (_PluginOptions[0].Value == "False")
return;
foreach (IItem sourceTemplate in sourceItem.Templates)
{
// Check if the correct template exists on the item
if (sourceTemplate.Name.ToLower() != _PluginOptions[3].Value.ToLower())
continue;
IField field = Util.GetFieldByName("__publish", destinationItem.Fields);
if (field == null)
{
field = Util.GetFieldByName("__valid to", destinationItem.Fields);
if (field == null)
{
field = Util.GetFieldByName("__created", destinationItem.Fields);
}
}
if (field == null)
throw new Exception("Error finding any valid date field in " + this.Name + " plugin.");
DateTime date = Util.XsdDatetimeToDateTime(field.Content);
string sDate = date.ToString(_PluginOptions[1].Value);
string sYearPath = destinationParentItem.Path + "/" + sDate;
IItem yearFolder = destinationParentItem.GetItem(sYearPath);
if (yearFolder == null)
{
string sFolderID = destinationParentItem.AddFromTemplate(sDate, "/sitecore/templates/common/folder");
yearFolder = destinationItem.GetItem(sFolderID);
}
bool bResult = false;
if (_PluginOptions[2].Value == "")
bResult = destinationItem.MoveTo(yearFolder);
else
{
string sMonth = date.ToString(_PluginOptions[2].Value);
IItem monthFolder = destinationParentItem.GetItem(sYearPath + "/" + sMonth);
if (monthFolder == null)
{
string sFolderID = yearFolder.AddFromTemplate(sMonth, "/sitecore/templates/common/folder");
monthFolder = destinationItem.GetItem(sFolderID);
monthFolder.SortOrder = date.ToString("MM");
monthFolder.Save();
}
destinationItem.MoveTo(monthFolder);
}
}
}
示例2: CopyItemCallback
public void CopyItemCallback(IItem sourceItem, IItem destinationParentItem, IItem destinationItem)
{
if (_PluginOptions[0].Value == "False")
return;
// We are copying from masters to branches
if ((sourceItem.Path.ToLower().IndexOf("/sitecore/masters") > -1) &&
(destinationItem.Path.ToLower().IndexOf("/sitecore/templates/branches") > -1) &&
(!sourceItem.Name.StartsWith("__")) && (sourceItem.Name != "masters"))
{
Sitecore6xItem destination6xItem = destinationItem as Sitecore6xItem;
Sitecore6xItem destinationParent6xItem = destinationParentItem as Sitecore6xItem;
IItem newDestinationItem = destinationParent6xItem.GetItem(destinationParent6xItem.Path + "/$name");
if (newDestinationItem == null)
{
destination6xItem.CopyTo(destinationParentItem, "$name");
newDestinationItem = destinationParent6xItem.GetItem(destinationParent6xItem.Path + "/$name");
string sPath = destinationParent6xItem.CreateTemplateItemWithSpecificID(
destinationParent6xItem.ID,
"/sitecore/templates/System/Branches/Branch",
sourceItem.ID,
sourceItem.Name);
Sitecore6xItem branchItem = destinationParentItem.GetItem(destinationParent6xItem.Path + "/" + sourceItem.Name) as Sitecore6xItem;
newDestinationItem.MoveTo(branchItem);
if (destination6xItem.Icon != "")
branchItem.Icon = destination6xItem.Icon;
else
branchItem.Icon = destination6xItem.Templates[0].Icon;
branchItem.Save();
}
// This is a child of a master, so it only needs to be moved
else
{
destinationItem.MoveTo(newDestinationItem);
}
}
}