Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Oct 13, 2020 @ 16:44
    Matt Barlow | jacker.io
    0

    Context aware "Infinite Editing" (Block List), how to get a reference to the page doctype in SendingContentModel event?

    Hi all,

    I have a composition that contains a Block List Editor property, this composition is used on two document types. For example:

    Doctype1

    • BlockListProp (from composition)
      • blockDocType1
      • blockDocType2 ...

    Doctype2

    • BlockListProp (from composition)
      • blockDocType1
      • blockDocType2 ...

    Now I want to hook into the SendingContentModel, and set properties as read-only for blockDocType1 that sits as part of Doctype1, but crucially they should not be made read-only for Doctype2.

    So when I click to edit the block, the editor pane opens and code below is fired:

    Psuedo(ish) code:

    EditorModelEventManager.SendingContentModel += SetReadOnlyProperties;
    
     private void SetReadOnlyProperties(HttpActionExecutedContext sender, EditorModelEventArgs<ContentItemDisplay> editor)
     {
        if (editor.Model.ContentTypeAlias == blockDocType1.Alias)
       {
           //AND IF  base page is Doctype1  <---- IMPORTANT BIT
          // then do some readonly stuff
          // eg:
           foreach (var variant in editor.Model.Variants)
            {
                foreach (var tab in variant.Tabs)
                {
                    foreach (var prop in tab.Properties)
                    {   
                            prop.Readonly = true;
                    }
                }
            }
       }
     }
    

    So somehow I need to have the context of the page DocType inside this event. Is this even possible with infinite editing? If so how would I retrieve it?

    Thanks in advance!

    • M
  • Sven 34 posts 138 karma points
    Jun 30, 2022 @ 09:06
    Sven
    0

    Hello Matt,

    Did you find a solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft