我一直试图在Umbraco 7中以编程方式取消发布内容,但似乎没有按预期工作.虽然内容已从缓存中删除,但数据库记录从未更新过:
node.UnPublish();
umbraco.library.UnPublishSingleNode(node.Id);
Run Code Online (Sandbox Code Playgroud)
经过进一步调查,我发现UnPublishSingleNode方法已经过时了:
[Obsolete("This method is no longer used,
a document's cache will be removed automatically
when the document is deleted or unpublished")]
public static void UnPublishSingleNode(int DocumentId);
Run Code Online (Sandbox Code Playgroud)
该消息没有提出新的方法:(
我需要有关如何以编程方式取消发布内容的说明.
Umbraco版本: 7.3.3
我终于完成了它 Umbraco.Core.Services.IContentService
用法:
var contentServices = ApplicationContext.Current.Services.ContentService;
var content = contentServices.GetById(node.Id);
contentServices.UnPublish(content, 0);
Run Code Online (Sandbox Code Playgroud)
我希望这有助于其他人.
归档时间: |
|
查看次数: |
1039 次 |
最近记录: |