eat*_*ode 2 sitecore sitecore-mvc sitecore8
我想构建一个Sitecore管道处理器,它可以在上传媒体项时获取媒体项的ID,并将该ID保存到第三方应用程序使用的现有自定义数据库中.
我一直无法找到任何方法或示例如何做到这一点?
我正在使用Sitecore 8.0 Update 5和我的代码的MVC结构.
您可以检查uiUpload管道,但不会为编程创建的项目触发,即只有当用户通过CMS界面上传项目时才会触发.
创建一个新的处理器类:
public class ExternalSystemProcessor
{
public void Process(UploadArgs args)
{
foreach (Item file in args.UploadedItems.Where(file => file.Paths.IsMediaItem))
{
// Custom code here
SaveToExternalSystem(file.ID);
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后在默认保存处理器之后修补:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<processors>
<uiUpload>
<processor type="MyProject.Custom.Pipelines.ExternalSystemProcessor, MyProject.Custom" mode="on"
patch:after="*[@type='Sitecore.Pipelines.Upload.Save, Sitecore.Kernel']" />
</uiUpload>
</processors>
</sitecore>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2904 次 |
| 最近记录: |