November Happy Hour will be moved to Thursday December 5th.

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

Vote:
 

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
Vote:
 

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 09, 2019 12:37
Vote:
 

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

#201218
Feb 09, 2019 12:41
Vote:
 

Thanks Mattias !

#201714
Feb 28, 2019 8:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.