templates - 站点核心 8 : Change of datasource template for a sublayout

标签 templates sitecore sitecore8 sublayout

我对子布局的数据源模板的更改有疑问。现在,有两个子布局:Sub1Sub2,它们将 Template1 作为它们的数据源模板。直到我发现我需要为 Sub1 使用不同的数据源模板时,我已经创建了许多子布局 Sub1 和 Sub2 项。

Template2 现在将替换 Template1 作为子布局 Sub1 的数据源模板。 现在,我必须将使用子布局创建的所有项目的模板更改为 Sub1。

问题是我必须通过内容编辑器-->配置-->更改模板技术手动更改每个项目的模板,这非常麻烦。有没有其他方法可以一次更改所有这些项目的模板?

最佳答案

我建议你安装Sitecore PowerShell Extensions并使用 Sitecore PowerShell 控制台更改模板。

$master = [Sitecore.Configuration.Factory]::GetDatabase("master");
$entryTemplate = $master.Templates["your path to template Sub2"];
cd master:\Content\Home\Sub1FolderItems\;
//path to sub1 folder items
Get-ChildItem -recurse | ForEach-Object { if ($_.TemplateName -eq "Sub1") {  $_.ChangeTemplate($entryTemplate) } };

关于templates - 站点核心 8 : Change of datasource template for a sublayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34036539/

相关文章:

templates - Jade 兰 CMS : Introducing Magnolia tutorial not working with Magnolia CE and EE

objective-c - 为什么在 XCode4 中创建新的 Objective-C 类文件不会创建 "An Objective-C class, with a header that includes the <Cocoa/Cocoa.h> header."

sitecore - 创建时根据日期字段进行存储的项目

Sitecore MVC 确保在体验编辑器中可选择空占位符

solr - 推荐的带有 Sitecore 8.1(更新 1)的 SOLR 安装程序

c++ - 获取 C++ 模板参数包的总大小(以字节为单位)

c++ - 混淆定义静态 C++ 模板类成员

Sitecore 获取存档项目

google-analytics - 通过Sitecore CMS将HTML代码插入页面模板

asp.net-mvc-5 - 使用 Glass Mapper 的 Sitecore 8 可编辑字段