PageChangedOnPublish

Vote:
 
Is it possible to affect the "Page changed on publish"-checkbox in edit mode for a page to make it set by default (and allow the editor to manually uncheck it)? I've tried hooking up EPDataFactory_LoadedPage to set e.Page.Property["PageChangedOnPublish"].Value=true, but it doesn't seem to affect the checkbox at all.
#13056
May 31, 2007 10:32
Vote:
 
I've just made this (this morning actually). I looked around a bit and found a code sample that I modified. This creates a hidden editpanel that can be used for other purposes as well, such as hooking on javascript on submit button. [EPiServer.PlugIn.GuiPlugIn(DisplayName = "hidden", Description = "edit hooks", Area = EPiServer.PlugIn.PlugInArea.EditPanel, Url = "~/templates/Plugins/EditHiddenHooks.ascx") ] public class EditHiddenHooks : UserControlBase, ICustomPlugInLoader { PlugInDescriptor[] ICustomPlugInLoader.List() { PlugInDescriptor[] plugins = new PlugInDescriptor[0]; this.PageBase.PreRender += new EventHandler(Page_PreRender); return plugins; } private void Page_Load(object sender, System.EventArgs e) { } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Page_PreRender(object sender, EventArgs e) { // first Find active tab control //index 0 = PreView //index 1 = Edit //index 2 = VersionList Page page = (Page)sender; if (page != null && page.Controls.Count > 0) { int activeTab = GetActiveTab(page.Controls[0]); switch (activeTab) { //We are only interested to handle publish button on PreView or Edit tab case 0: break; case 1: MarkPageAsChanged(page.Controls[0]); break; default: break; } } } //Recursive function that finds tab ctrl and returns index of the currently active tab private int GetActiveTab(Control ctrl) { if (ctrl is EPiServer.SystemControls.Tab) { EPiServer.SystemControls.Tab command = (EPiServer.SystemControls.Tab)ctrl; if (command.Active) return command.Index; } //If not found check child ctls foreach (Control child in ctrl.Controls) { int tab = GetActiveTab(child); if (tab != -1) return tab; } return -1; } //Function that finds ctrl of type CommandTool (publish button e.g.) with name Publish. //It will then add a client javascript to the control for clientside confirmation private void MarkPageAsChanged(Control ctrl) { System.Web.UI.Control c = FindCheckBoxRecursive(ctrl, "PageChangedOnPublish"); if (c != null) ((CheckBox)c).Checked = true; } /// /// Search recurisively for a control. /// /// Root control whos children and sub children will be searched. /// The ID of the control to search for. /// Returns found control or null if no control is found. private System.Web.UI.Control FindCheckBoxRecursive(System.Web.UI.Control RootControl, String ControlID) { if (RootControl != null) { System.Web.UI.Control tmpCtrl = RootControl.FindControl(ControlID); if (tmpCtrl != null && tmpCtrl is System.Web.UI.WebControls.CheckBox) return tmpCtrl; foreach (System.Web.UI.Control c in RootControl.Controls) { tmpCtrl = FindCheckBoxRecursive(c, ControlID); if (tmpCtrl != null && tmpCtrl is System.Web.UI.WebControls.CheckBox) return tmpCtrl; } } return null; } }
#15330
Jun 01, 2007 10:34
Vote:
 
Thank you very much! Greatly appreciated!
#15331
Jun 01, 2007 15:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.