如何在Tridion 2011 SP1中使用Core Service创建期间向页面添加组件演示文稿

Pat*_*tan 3 tridion

我正在通过核心服务创建一个页面.我想添加组件演示文稿.

我创建了这样的页面:

var page = new Tridion.ContentManager.CoreService.Client.PageData
{
    Title = "pagecore",
    FileName = "pagecore",
    Id = "tcm:0-0-0",
    LocationInfo = new LocationInfo
    {
        OrganizationalItem = new LinkToOrganizationalItemData { IdRef = "tcm:9-44-4" }
    },
    IsPageTemplateInherited= false,
    PageTemplate=new LinkToPageTemplateData { IdRef = "tcm:9-545-128" }, 
}
Run Code Online (Sandbox Code Playgroud)

我无法向其添加组件演示文稿.

任何人都可以告诉我如何添加组件演示文稿吗?

谢谢.

And*_*huk 7

您需要将ComponentPresentationData对象集合设置为ComponentPresentations属性PageData,如下所示:

ComponentPresentations = new[]
{
   new ComponentPresentationData
   {
       Component = new LinkToComponentData{ IdRef = "tcm:9-16"},
       ComponentTemplate = new LinkToComponentTemplateData{ IdRef = "tcm:9-20-32"}
   }, 
}
Run Code Online (Sandbox Code Playgroud)