简体   繁体   English

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

[英]How to add component presentations to a page during creation using Core Service in Tridion 2011 SP1

I am creating a page through the core service. 我正在通过核心服务创建一个页面。 I want to add component presentations to it. 我想添加组件演示文稿。

I have created the page like this: 我创建了这样的页面:

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" }, 
}

I am unable to add component presentations to it. 我无法向其添加组件演示文稿。

Can any one tell me how to add the component presentations? 任何人都可以告诉我如何添加组件演示文稿吗?

Thank you. 谢谢。

You need to set collection of ComponentPresentationData objects to ComponentPresentations property of PageData , like this: 您需要将ComponentPresentationData对象的集合设置为PageData ComponentPresentations属性,如下所示:

ComponentPresentations = new[]
{
   new ComponentPresentationData
   {
       Component = new LinkToComponentData{ IdRef = "tcm:9-16"},
       ComponentTemplate = new LinkToComponentTemplateData{ IdRef = "tcm:9-20-32"}
   }, 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM