本文整理汇总了C#中Item.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Add方法的具体用法?C# Item.Add怎么用?C# Item.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_item1 = _testRoot.Add("item1", _template);
_item2 = _testRoot.Add("item2", _template);
_subItem1 = _item1.Add("subitem1", _template);
_subItem2 = _item1.Add("subitem2", _template);
}
示例2: CreateAlphabetFolderStructure
/// <summary>
/// Creates an alphabet folder structure under the passed in parent. This will also inlcude 123 as a folder
/// for handling items that start with numbers.
/// </summary>
/// <param name="parentItem">The parent item.</param>
/// <param name="folderTemplate">The folder template.</param>
/// <param name="upperCase">if set to <c>true</c> make the letter folder name upper case.</param>
public static void CreateAlphabetFolderStructure(Item parentItem, TemplateItem folderTemplate, bool upperCase)
{
if (parentItem == null || folderTemplate == null) return;
Database masterDb = Factory.GetDatabase("master");
using (new SecurityDisabler())
{
foreach (string letter in alphabetFolderNames)
{
//If we are supposed to make the folder name upper case, do so
string folderName = letter;
if (upperCase)
{
folderName = folderName.ToUpper();
}
//Only add the folder if it does not already exist, this way this method can be used to fill
// in missing folders in an already existing partial alpha folder structure.
string letterFolderPath = string.Format("{0}/{1}", parentItem.Paths.Path, folderName);
Item alphaFolder = SitecoreItemFinder.GetItem(masterDb, letterFolderPath);
if (alphaFolder == null)
{
parentItem.Add(letter.ToUpper(), folderTemplate);
}
}
}
}
示例3: TestFixtureSetUp
public void TestFixtureSetUp()
{
var db = Sitecore.Configuration.Factory.GetDatabase("web");
var folder = db.GetTemplate("Common/Folder");
var page = db.GetTemplate("dc2011/page");
var home = db.GetItem("/sitecore/content/dc2011");
using (new SecurityDisabler())
{
m_testRoot = home.Add("test", folder);
m_pageWithTitle = m_testRoot.Add("withtitle", page);
m_pageWithTitle.Editing.BeginEdit();
m_pageWithTitle["title"] = "Different Title";
m_pageWithTitle.Editing.EndEdit();
m_pageNoTitle = m_testRoot.Add("notitle", page);
m_testRoot.Paste(File.ReadAllText(@"test data\Category Items.xml"), true, PasteMode.Overwrite);
m_categoryItems = m_testRoot.Axes.GetChild("Project List");
}
}
示例4: CreateTestContentItem
private Item CreateTestContentItem(Item item, TemplateItem template, string name, string content)
{
var child = item.Add(name, template);
child.Editing.BeginEdit();
child["content"] = content;
child.Editing.EndEdit();
return child;
}
示例5: CreateTestContentItem
private Item CreateTestContentItem(Item item, string name, string content)
{
var template = item.Database.Templates["sample/sample item"];
var child = item.Add(name, template);
child.Editing.BeginEdit();
child["text"] = content;
child.Editing.EndEdit();
return child;
}