在Kentico中如何设置'DocumentShowInSiteMap' 属性的值?
How do you set the value of 'DocumentShowInSiteMap' property in Kentico?
在Kentico中如何设置DocumentShowInSiteMap
属性的值?
我试过:
- 使用
DocumentHelper
和 TreeHelper
API,但同时使用这两个 API,此 属性 无法让您访问 setter.
- 已尝试 运行 设置 SQL 查询将
dbo.CMS_Document.DocumentShowInSiteMap
的值设置为 1
和 0
。这些查询 运行 很好,但是当我转到页面应用程序时,' 在站点地图中显示 ' 属性 复选框没有变化,即。将数据库字段设置为 0 不会 'untick' 此复选框。
我正在尝试 运行 一项计划任务,该任务会自动为指定位置的文档设置此 属性。这样做的正确方法是什么?任何帮助表示赞赏。
在代码中,没有简单的方法。 Setter 应该在特殊的 class DocumentCultureDataInfo 中可用,并且应该用 SetObject 保存。此 class 包含所有文化数据库字段并由 DocumentCultureDataInfoProvider 操作。
此 class 是 TreeNode 的内部 属性。但是我没有尝试在代码中任意执行此操作,并提到 classes 是 innner API.
的一部分
您的第二种方法应该可行,但文档及其属性已缓存,您将需要刷新缓存以便实际获取新的数据库值加载此 属性 通过 LoadDefaultValues 中的简单 GetData 为每个树节点。
你试过吗?
int TheDocumentToModify = 1221;
var PageItem = DocumentHelper.GetDocument(TheDocumentToModify , new TreeProvider());
foreach(var culturePage in PageItem.CultureVersions)
{
culturePage.SetValue("DocumentShowInSiteMap", true);
// May need to apply Workflow check in / check out, see Kentico API examples based on your need.
culturePage.Update();
}
Trevor J Fayas 的回答可能会奏效。我昨天想通了,只是把我的解决方案留在这里以防万一:
TreeHelper
.GetDocuments(task.CurrentSiteName, aliaspath, null, false, "", "", "", -1, false, -1)
.Where(doc => doc.DocumentShowInSiteMap)
.ToList()
.ForEach(node =>
{
node.SetValue("DocumentShowInSiteMap", false);
node.Update();
});
显然用你需要的替换 aliaspath
或使用带有不同参数的 DocumentHelper.GetDocuments
。
在Kentico中如何设置DocumentShowInSiteMap
属性的值?
我试过:
- 使用
DocumentHelper
和TreeHelper
API,但同时使用这两个 API,此 属性 无法让您访问 setter. - 已尝试 运行 设置 SQL 查询将
dbo.CMS_Document.DocumentShowInSiteMap
的值设置为1
和0
。这些查询 运行 很好,但是当我转到页面应用程序时,' 在站点地图中显示 ' 属性 复选框没有变化,即。将数据库字段设置为 0 不会 'untick' 此复选框。
我正在尝试 运行 一项计划任务,该任务会自动为指定位置的文档设置此 属性。这样做的正确方法是什么?任何帮助表示赞赏。
在代码中,没有简单的方法。 Setter 应该在特殊的 class DocumentCultureDataInfo 中可用,并且应该用 SetObject 保存。此 class 包含所有文化数据库字段并由 DocumentCultureDataInfoProvider 操作。
此 class 是 TreeNode 的内部 属性。但是我没有尝试在代码中任意执行此操作,并提到 classes 是 innner API.
的一部分您的第二种方法应该可行,但文档及其属性已缓存,您将需要刷新缓存以便实际获取新的数据库值加载此 属性 通过 LoadDefaultValues 中的简单 GetData 为每个树节点。
你试过吗?
int TheDocumentToModify = 1221;
var PageItem = DocumentHelper.GetDocument(TheDocumentToModify , new TreeProvider());
foreach(var culturePage in PageItem.CultureVersions)
{
culturePage.SetValue("DocumentShowInSiteMap", true);
// May need to apply Workflow check in / check out, see Kentico API examples based on your need.
culturePage.Update();
}
Trevor J Fayas 的回答可能会奏效。我昨天想通了,只是把我的解决方案留在这里以防万一:
TreeHelper
.GetDocuments(task.CurrentSiteName, aliaspath, null, false, "", "", "", -1, false, -1)
.Where(doc => doc.DocumentShowInSiteMap)
.ToList()
.ForEach(node =>
{
node.SetValue("DocumentShowInSiteMap", false);
node.Update();
});
显然用你需要的替换 aliaspath
或使用带有不同参数的 DocumentHelper.GetDocuments
。