0

When using "Insert page" in Experience Editor you get redirected to the newly created page/item (after choosing the template and the item name).

How can I modify this redirect URL so that I can add a custom query string parameter, or even redirect to a completely different item?

Sitecore 8.2 Update 5

  • 1
    What are you trying to achieve via the query string? – Richard Seal Jul 17 '18 at 14:33
0

As you did not specify the Sitecore version I will assume that you use Sitecore.NET 9.0.2 (rev. 180604) or your version uses a similar approach.

  1. Open core database
  2. Find following item /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit/Insert
  3. In Renderings field there is a button definition, where you will find source of assets (js) and ID of the pipeline that will be called once you click the button in EE. Pipeline ID is {DF6345DC-ACC8-43B4-BC08-DFBF29906505}
  4. Find {DF6345DC-ACC8-43B4-BC08-DFBF29906505} item in core database.

Now you can extend pipeline by adding new processors or overwriting existing processors if needed. Right now I can see two processors: openInsertItemDialog and insert.

Code is located here: site\sitecore\shell\client\Sitecore\ExperienceEditor\Pipelines\InsertItem\

Older versions (7.5 rev. 150130 >)

If you are using an older Sitecore version you might not find steps above applicable. Here are steps for older Sitecore version.

  1. Open core database
  2. Find following item /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit/Insert
  3. In Click field there is a name of the command that will be executed when you click the button in EE (webedit:new)
  4. Open config http://site/sitecore/admin/ShowConfig.aspx and find following string webedit:new.
  5. Overwrite this command (search for something like this when you decompile source code (SheerResponse.Eval("scNavigate(\"" + str + "\", 1)");)
| improve this answer | |
  • Sorry, I should have specified which Sitecore version I was running. Question is now updated with that information. However, I tried your "Older versions" and decompiled Sitecore.Shell.Applications.WebEdit.Commands.New, copied the code to my own project (and changed namespace accordingly), and created a custom config file that points to my webedit:new command instead of the built in one (and confirmed that this config file was added by checking that admin/ShowConfig.aspx now includes my namespace instead of the original one). However, none of the methods in my class are hit :( – GTHvidsten Jul 18 '18 at 9:07
  • @GTHvidsten try the first approach. I am not sure when Sitecore has changed the approach. By "older" I meant versions for which the first approach does not apply. – Alan Płócieniak Jul 19 '18 at 12:11
  • You assumed Sitecore 9, so I assumed the older would be for me :) I tried the first approach and could find some JS file, which were sort of understandable. I had hoped, though, that there would be some server-side solution so that I could more easily check templates/parents/links/whatever. The only server-side seems to be the handler associated with webedit:new, which didn't work. Unless you have some other tricks up your sleeve it would seem like this would is kinda impossible? – GTHvidsten Jul 19 '18 at 13:06
  • If you examine carefully logic in JS you will find that you can communicate with a server via ExperienceEditor.PipelinesUtil.generateRequestProcessor. The first argument is the name of the request (you will find it in the config). You can create your own request type and do whatever you want on the server side. You just have to make sure that you pass enough information via request. I recommend you to investigate existing requests. Good luck – Alan Płócieniak Jul 19 '18 at 18:43
  • After more investigation I can finally work out how the ExperienceEditor pipelines work, and I could modify the existing ExperienceEditor.Insert request to change which item is returned to ExperienceEditor, which then redirects to this item instead of the newly created item. However, I can see that the JS pipeline calls response.context.app.refreshOnItem() which is what ends up doing the actual redirect. This method is not part of any pipelines. Which means I'm not able to add additional info to the query string :( – GTHvidsten Jul 20 '18 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.