【问题标题】:How to create a Structure Group in SDL Tridion 2011 using core services?如何使用核心服务在 SDL Tridion 2011 中创建结构组?
【发布时间】:2012-05-31 07:28:53
【问题描述】:

我想在 Tridion 2011 中使用核心服务创建一个结构组 有什么想法吗?

【问题讨论】:

  • 你试过了吗?真的需要在这里问怎么做需要3行代码的事情吗?

标签: tridion


【解决方案1】:

这是代码:

var structureGroup = ClientAdmin.GetDefaultData(ItemType.StructureGroup, "tcm:0-2-1");
structureGroup.Title = "SG";
structureGroup.Directiry = structureGroup.Title.Replace(" ", ""),
structureGroup = (StructureGroupData) ClientAdmin.Create(structureGroup, new ReadOptions());

我认为这里不需要任何解释,如果您想了解更多信息,请查看 CoreService API 文档中的 StructureGroupData

【讨论】:

  • 您也可以指定另一个结构组作为父项,而不是发布 ("tcm:0-2-1")。
【解决方案2】:

上面的代码似乎不是标准的核心服务 API。检查这个。

CoreServiceClient channel = new CoreServiceClient("basicHttp_2011");
string organizationalItemId = "tcm:6-3-4";
StructureGroupData sg = new StructureGroupData();
sg.Id = "tcm:0-0-0";
sg.Title = "NewSG";
sg.LocationInfo = new LocationInfo() { OrganizationalItem = new LinkToOrganizationalItemData() { IdRef = organizationalItemId } };
sg.Directory = "NewSG";
sg = (StructureGroupData)channel.Save(sg, new ReadOptions());

您可能会注意到,Directory 属性不能包含空格。那是因为它是通过正则表达式验证的。您可以在位于 [TRIDION_HOME]\bin 的文件 cm_xml_usr.xsd 中更改它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-11
    • 1970-01-01
    • 2012-04-21
    • 2012-03-24
    • 1970-01-01
    • 2012-12-30
    • 2012-05-13
    • 1970-01-01
    相关资源
    最近更新 更多