小编dan*_*mac的帖子

使用renderingDefinition.ItemId以编程方式将sitecore渲染复制到新模板?

我有一个自定义的sitecore按钮,它可以更改当前项目的模板,非常简单.

然而,作为其中的一部分,我还试图将旧布局的渲染转换为新布局,如果它是某种子布局类型的话ItemId.但是ItemId返回的值始终为null,我从中获取的唯一值RenderingDefinitionUniqueId.

我究竟做错了什么?

我曾将此博客文章作为指南.

代码

public class ConvertToNewTemplateCommand : Command
{
protected void Run(ClientPipelineArgs args)
{
    if (!SheerResponse.CheckModified())
        return;

    Item item = Context.ContentDatabase.Items[args.Parameters["id"]];
    if (args.IsPostBack)
    {
        if (args.Result == "yes")
        {
            //Get current layout details
            var originalLayoutXml = item[FieldIDs.LayoutField];

            //Get new template
            TemplateItem hubTemplate = Context.ContentDatabase.GetTemplate("some guid...");
            //Change template  
            item.ChangeTemplate(hubTemplate);
            //Reset laytout
            ResetLayout(item);
            //Get reset layout
            var newLayoutXml = item[FieldIDs.LayoutField];

            //Add all the module containers to the new layout in …
Run Code Online (Sandbox Code Playgroud)

rendering sitecore sitecore6 sublayout

6
推荐指数
1
解决办法
1338
查看次数

标签 统计

rendering ×1

sitecore ×1

sitecore6 ×1

sublayout ×1