当我尝试为现有模板创建新项目时,我是sitecore的新手。我无法调用我的master数据库。需要一些指导如何在sitecore中创建新项目以及如何在我正在运行的sitecore页面上显示它?只需要一些关于创建后流程的提示,如何在现有的sitecore页面上呈现它。
<configuration type="Sitecore.Search.SearchConfiguration, Sitecore.Kernel" singleInstance="true">
<indexes hint="list:AddIndex">
<index id="system" type="Sitecore.Search.Index, Sitecore.Kernel">
<param desc="name">$(id)</param>
<param desc="folder">__system</param>
<Analyzer ref="search/analyzer" />
<locations hint="list:AddCrawler">
<core type="Sitecore.Search.Crawlers.DatabaseCrawler,Sitecore.Kernel">
<Database>core</Database>
<Root>/sitecore/content</Root>
<include hint="list:IncludeTemplate">
<application>{EB06CEC0-5E2D-4DC4-875B-01ADCC577D13}</application>
</include>
<Tags>application</Tags>
<Boost>2.0</Boost>
</core>
<core-controlpanel type="Sitecore.Search.Crawlers.DatabaseCrawler,Sitecore.Kernel">
<Database>core</Database>
<Root>/sitecore/content/applications/control panel</Root>
<include hint="list:IncludeTemplate">
<taskoption>{BDB6FA46-2F76-4BDE-8138-52B56C2FC47E}</taskoption>
</include>
<Tags>taskoption</Tags>
<Boost>1.9</Boost>
</core-controlpanel>
<master type="Sitecore.Search.Crawlers.DatabaseCrawler, Sitecore.Kernel">
<Database>master</Database>
<Tags>master content</Tags>
</master>
</locations>
</index>
</indexes>
</configuration>
答案 0 :(得分:1)
我将编写我经常执行的代码:
Database database = Database.GetDatabase("master");
Item rooItem = database.GetItem(new ID(parentItemId));
if (rootItem == null) return null;
TemplateID pageTemplateId = new TemplateID(new ID(templateId));
string validName = ItemUtil.ProposeValidItemName(name);
using (new Sitecore.SecurityModel.SecurityDisabler())
{
Item newItem = rootItem.Add(validName, pageTemplateId);
if (newItem == null) return null;
//TODO: publish item
}