Sitecore saveUI processor redirecting to item page after moving it

感情迁移 提交于 2019-12-11 03:23:36

问题


I have implemented a Sitecore saveUI processor for moving news items to a specific location inside a year/month hierarchical structure. It does the job well, except for the fact that when used inside the Page Editor (navigating to an item's page and then trying to save, and implicitly move, the item) I am redirected to our 404 page, since Sitecore expects the original item's url to still be valid after the operation.
Is there any way to tell Sitecore that the item has been moved? I'm thinking at some property in SaveArgs, but any solution would do, as long as it's somewhat maintainable (for example, I'd prefer a server-side solution, not a client-side JavaScript-based one, if possible).


回答1:


Off the top of my head, make sure your processor the last one in the pipeline and add the following code to the end of the process method:

if(Sitecore.Context.PageMode.IsPageEditor)
{
    var item = args.SavedItems.First() // or perhaps Context.Item;
    var url = LinkManager.GetItemUrl(item);
    HttpContext.Current.Response.Redirect(url);
}



回答2:


Have you tried using the Sitecore Newsmover Module? This works seamlessly and could be the way to go instead of creating custom movers. We have used this plenty of times and it does seem to work well in all conditions.

Sample config for this:

    <template id="User Defined/News Article" sort="Descending">
      <DateField>Posted Date</DateField>
      <YearTemplate formatString="yyyy">User Defined/Folders/Article Year Folder</YearTemplate>
      <MonthTemplate formatString="MMMM">User Defined/Folders/Article Month Folder</MonthTemplate>
    </template>


来源:https://stackoverflow.com/questions/24065457/sitecore-saveui-processor-redirecting-to-item-page-after-moving-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!