Per Nergård
Jun 16, 2010
  6487
(0 votes)

Mark page as changed checked as default

If you check the EPiServer SDK they way to do it is by attaching to the EditPanel loadedpage event i Global.asax.

What if you would like to to it for different pagetypes then? It would be no big thing to add a paget ype check and maybe make it configurable through a section i web.config.

Since I don’t like neither sections in web.config or having lot’s of code in global.asax i decided to try to accomplish this with a custom property.

It turned out to be very straight forward. Just create a custom property with a control class inheriting from PropertyStringControl, and add the below code to CreateEditControls.

Just add the property to the top of the Information tab and you should be good to go.

Note: After having so colleagues trying it out it seems that neither of the two approaches work i CMS5 R2, but both do in CMS5.

   1: #region CreateEditControls
   2:     /// <summary>
   3:     /// Set "PageChangedOnPublished
   4:     /// </summary>
   5:     public override void CreateEditControls()
   6:     {
   7:         PageData pd = ((PageBase)this.Page).CurrentPage;
   8:  
   9:         if (pd.Property["PageChangedOnPublish"] != null)
  10:             pd.Property["PageChangedOnPublish"].Value = "True";
  11:  
  12:     }
  13:     #endregion

 

Global.asax code:

   1: public class Global : EPiServer.Global
   2: {
   3:     protected void Application_Start(Object sender, EventArgs e)
   4:     {
   5:         EditPanel.LoadedPage += new LoadedPageEventHandler(EditPanel_LoadedPage);
   6:     }
   7:  
   8:     protected void EditPanel_LoadedPage(EditPanel sender, LoadedPageEventArgs e)
   9:     {
  10:         e.Page.PageName += "[Test]";
  11:         e.Page["PageChangedOnPublish"] = true;
  12:     }
  13: }
Jun 16, 2010

Comments

Falted
Falted Sep 21, 2010 10:33 AM

Have you tried this approach in CMS 6?

Sep 21, 2010 10:33 AM

Yes I tagged it with CMS 6 so i should have done it in cms 6.

mpagi.kironde@rufusleonard.com
mpagi.kironde@rufusleonard.com Sep 11, 2012 05:58 PM

HI Per,

I tried your solution in version 5.2.375.236, but no luck. Its driving me up the wall, Any ideas how to get it workin in 5.2

thanks

Apr 4, 2013 05:33 PM

Sorry that I haven't answered. There is some problem because I don't get any mails when people comment altough I have it in the settings.

I think this is a known limitation that it doesn't work in CMS5.

Marcus Andersson
Marcus Andersson Jun 18, 2013 11:02 AM

Exactly what I was looking for!
Thanks.

Please login to comment.
Latest blogs
Creating an Optimizely CMS Addon - Adding an Editor Interface Gadget

In   Part One   of this series, I covered getting started with creating your own AddOn for Optimizely CMS 12. This covered what I consider to be an...

Mark Stott | Aug 30, 2024

Configure your own Search & Navigation timeouts

The main blog Configure your own Search & Navigation timeouts was posted for years but you need copy the code to your application. We now bring tho...

Manh Nguyen | Aug 30, 2024

Joining the Optimizely MVP Program

Andy Blyth has been honoured as an Optimizely MVP, recognising his contributions to the Optimizely community. Learn how this achievement will enhan...

Andy Blyth | Aug 29, 2024 | Syndicated blog

Welcome 2024 Summer OMVPs

Hello, Optimizely community! We are thrilled to announce and welcome the newest members to the Optimizely Most Valuable Professionals (OMVP) progra...

Patrick Lam | Aug 29, 2024

Create custom folder type in Edit Mode

Content Folders, which are located in assets pane gadget or multichannel content gadget, allow you to add any type of block or folders. But...

Grzegorz Wiecheć | Aug 28, 2024 | Syndicated blog

Creating an Optimizely AddOn - Getting Started

When Optimizely CMS 12 was launched in the summer of 2021, I created my first AddOn for Optimizely CMS and talked about some of the lessons I learn...

Mark Stott | Aug 28, 2024