【发布时间】:2014-02-10 15:47:04
【问题描述】:
我正在使用我编写的导入脚本在新的 Umbraco v6.1.6 网站中创建大约 500 个页面。我正在使用 ContentService api 创建新页面。它们被创建并且似乎保存得很好。但是,如果我从其中一个新页面请求复选框列表的值,我会得到一个空字符串。
我已验证 umbraco.config 文件中的属性为空,但是如果我从 Umbraco 后台手动保存页面。缓存将更新为正确的值,我突然得到正确的返回值。
有没有办法针对这个问题强制更新缓存或其他形式的修复?
这是我正在使用的 CreateContent 方法:
public static IContent CreateContent(string name, string documentTypeAlias, int parentId, Dictionary properties, bool publish = false, int author = 0)
{
IContent document = null;
ContentService contentService = new ContentService();
document = contentService.CreateContent(
name, // the name of the document
parentId, // the parent id should be the id of the group node
documentTypeAlias, // the alias of the Document Type
author);
foreach (string property in properties.Keys)
{
document.SetValue(property, properties[property]);
}
// If publish is true, then save and publish the document
if (publish)
{
contentService.SaveAndPublish(document);
}
// Else, just save it
else
{
contentService.Save(document);
}
return document;
}
编辑:
查看数据库后,我可以看到 cmsContentXml 具有属性,但其中的数据与 umbraco.config 相同。我查看了 cmsPropertyData 并且数据存在。所以我想问题是如何将数据从 cmsPropertyData 获取到 cmsContentXml?
我的问题与这个问题相似:https://stackoverflow.com/questions/17722347/umbraco-6-1-1-when-i-publish-content-via-the-content-service-tags-type-property 但是它没有回复。
【问题讨论】:
-
属性字典中的值(对于您的复选框列表)如何格式化?如果您导入一个值,该值不会显示在 XML 缓存中,但如果您从后台保存,则听起来您的复选框属性在导入期间未正确保存。
标签: database caching content-management-system umbraco