Reputation: 31
I want to switch between languages in content editor programmatically after saving item in sitecore
Upvotes: 0
Views: 150
Reputation: 2115
One way to achieve the desired result is to add a processor to the saveUI
pipeline, that will reference ContentEditorDataContext
and will change its language. To do so, we need to create a class with Process
method like so:
public class LanguageChangeAfterSave
{
public void Process(Sitecore.Pipelines.Save.SaveArgs args)
{
var contentEditorDataContext = Sitecore.Context.ClientPage.FindControl("ContentEditorDataContext") as Sitecore.Web.UI.HtmlControls.DataContext;
contentEditorDataContext.Language = Language.Parse("en");
contentEditorDataContext.Refresh();
}
}
And in order to add this pipeline processor to the saveUI pipeline, we also create a .config file with the following content, and drop it to the webroot\App_Config\Include\ dirctory:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<processors>
<saveUI>
<processor type="YourNamespace.LanguageChangeAfterSave,YourAssembly" />
</saveUI>
</processors>
</sitecore>
</configuration>
Upvotes: 1