Sitecore - 在 OnSavingItem 事件上创建新项目会将 Shell 重定向到新创建的项目
遇到一个烦人的问题。
当用户编辑项目上的字段时,我们使用 OnSavingItem 事件处理程序在后台其他位置创建一些新项目。
问题是用户编辑字段的项目被重定向到我们在后台创建的不可见项目。
我们希望它保持在原来的位置...有什么想法吗?
谢谢
Got an annoying issue.
When a user edits a field on an item, we use a OnSavingItem event handler to create some new items elsewhere in the background as it were.
Problem is the item the users edited the field of gets redirected to the item we invisible created in the background.
We want it to stay where it is... Any ideas?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想禁用到刚刚创建的项目的传输,您还可以考虑实现以下代码:
If you want to disable the transfer to the item you've just created you could also consider implementing the following code:
您正在使用
处理程序吗?如果是这样,请不要忘记该事件也会在您创建的所有新项目上触发,从而可能触发递归事件循环。
Are you using the
Handler? If so, don't forget that this event is fired on all the new items you create as well, potentially triggering a recursive event loop.
这个答案来自 SiteCore 论坛...归功于 John West
我认为您可以使用 item: saving 事件或 saveUI 管道。如果您需要处理通过 API 发生的更改,请使用事件;如果您只需要处理通过用户界面发生的更改,请使用管道。
您还可以考虑将逻辑添加到字段本身。
约翰·韦斯特 Sitecore 博客
This answer came from the SiteCore forum ... credit goes to John West
I think you could use the item:saving event or the saveUI pipeline. Use the event if you need to handle changes that occur through APIs, or use the pipeline if you only need to handle changes that occur through the user interface.
You could also consider adding the logic to the field itself.
John West Sitecore Blog
item:saved 比 saveUI 管道中的处理器重得多。例如,item:saved 在发布过程中被触发,这不是您真正想要的。我始终建议在管道或工作流程操作级别处理此类自定义。
item:saved is much heavier than a processor within the saveUI pipeline. For example, item:saved is triggered during publishing which is not what you really want. I always recommend handling such customizations either on the pipeline or workflow action level.