To detect if "Visible in Menu" (Display in Navigation) property is updated

 

I am currently working on Episerver CMS 10.
The structure of our website is suct that it contains global page and local page.


Local page inherits some of the content of global page.

We have inherit factory class which updates the local page if some changes are made in global page .

The issue I am facing is

I have "visible in menu"(Display in navigation) option which is a bool property in both pages.


so when the checkbox is checked or unchecked in global

of "Visible in menu" then only update the local page.

how can we detect if the "visible in menu" (display in navigation) is changed  then update the

local page ?

#201215
Feb 09, 2019 4:32
Mattias Olsson
Member since: 2005
 

Hi!

I guess it should be possible to use the SavingContent event and load the published version of the page and compare it to the one being saved.

EDIT: I forgot one important thing in the code example below in the original post: .ToReferenceWithoutVersion() when loading the published page.

public static void SavingContent(object sender, ContentEventArgs e)
{
    var page = e.Content as PageData;

    if (page == null || ContentReference.IsNullOrEmpty(e.ContentLink))
    {
        return;
    }

    var publishedPage = contentRepository.Get<PageData>(e.ContentLink.ToReferenceWithoutVersion());
    
    if (page.VisibleInMenu != publishedPage.VisibleInMenu)
    {
        // Load local page and update it.
    }
}
#201216
Edited, Feb 11, 2019 13:37
Mattias Olsson
Member since: 2005
 

If you only want to do this for published pages you can use the PublishingContent event instead.

#201218
Feb 09, 2019 12:41
 

Thanks Mattias !

#201714
Feb 28, 2019 8:25