sitecore--发布目录时如何通过代码获取所有发布项
发布目录时如何通过代码获取所有发布项目以及我应该将处理程序添加到哪个事件,publish:begin
或 publish:itemProcessing
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布目录时如何通过代码获取所有发布项目以及我应该将处理程序添加到哪个事件,publish:begin
或 publish:itemProcessing
?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
如果您想要设置自定义事件处理程序,请从 web.config 参考开始。
然后创建一个支持此引用的类。
从此类中,您可以尝试访问发布者对象,该对象将为您提供已发布的根项目和发布选项。发布选项将告诉您是否发布了单个项目或是否发布了所有语言版本。
If you're looking to setup a custom event handler start with the web.config reference.
Then create a class that will support this reference.
From this class you can try to access the publisher object which will give you the root item published and publish options. The publish options will tell you if there was a single item published or if it published all versions of languages.
根据您的实际需求,将自定义处理器注入到publishItem管道中可能比使用”),您会发现这些事件(
publish:itemProcessing
事件更有意义。如果您仔细查看 web.config 中的该管道(搜索“publish:itemProcessing
和publish:itemProcessed
) 由管道的适当处理器生成。注意:发布过程相当复杂,我不建议对正在发布的项目进行任何可能影响总体过程的操作。我不能在这里给你一个例子 - 只有你的幻想设定了限制...
另请注意,对于这些事件以及我提到的管道,你一次操作 1 个项目 - 每个项目都会调用它正在发布的项目。这可能对性能至关重要...
更新:您可以在 这篇博文。除了本身有用之外,它还包含有关该主题的更多有用链接。
Depending on your real needs, it might make more sense to inject a custom processor into the publishItem pipeline rather than use
publish:itemProcessing
event. If you take a closer look at that pipeline (search for "<publishItem
") in web.config, you'll that those events (publish:itemProcessing
andpublish:itemProcessed
) are generated by the appropriate processors of pipeline.NOTE: the publishing process is rather complex and I would not recommend doing anything with the item being published that can influence the process in general. I can't give you an example here - only your fantasy sets the limits...
Note also, that with those events, as well as the pipeline I mentioned, you operate with 1 item at a time - it will be called for each item being published. This can become performance critical...
UPDATE: You can read more about pipeline in this blog post. Apart from being useful itself, it contains more useful links on the subject.