3

I have a saveUI processor and I only want to run my code if the user clicked the save button in Page Editor. I've tried checking the context like:

Sitecore.Context.PageMode.IsPageEditor

but it's always false. My guess is that the processor isn't in the right context.

How do I go about checking where the click was from? Is the "sender" indicated in the args somewhere?

Martin Davies
  • 4,436
  • 3
  • 19
  • 40
Scott
  • 1,011
  • 1
  • 15
  • 30
  • What code do you want to run? Resources outline that the saveUi pipeline should only be used when you need to interact with the user saving the item. So another may be more suitable which PageMode is maintained – Jonathan Robbins Jun 08 '15 at 09:17

1 Answers1

1

You should be able to correctly detect the PageMode in the Sitecore Context via

if (Sitecore.Context.PageMode.IsPageEditorEditing)

There are also options like

  • IsPageEditor
  • IsPageEditorDesigning
  • IsPageEditorClassic

If you have a look in the Sitecore.Context.PageMode namespace you will see all the options available to you so you can detect the mode you need.

I believe for older versions of Sitecore (possibly 6.5 and below) there were different properties.

I recommend looking at this post for additional information - https://www.sitecore.net/learn/blogs/technical-blogs/martina-welander-sitecore-blog/posts/2013/07/improving-the-page-editor-experience-part-3-detecting-page-mode.aspx

Martin Davies
  • 4,436
  • 3
  • 19
  • 40
Jonathan Robbins
  • 2,027
  • 1
  • 16
  • 30
  • As I said in my question, this is not working. IsPageEditorEdting, IsPageEditor, IsPageEditorDesigning and IsPageEditorClassic all return false within the saveUI processor even though the save click happens from Page Editor. The article you reference his about inline code in the page, not a pipeline. The code I'm running is in the saveUI pipeline, so I think the context is different there. – Scott Jun 03 '15 at 19:59
  • Sitecore.Context should still be accessible within pipelines. I'll check out my past examples and get back to you – Jonathan Robbins Jun 03 '15 at 20:59