Copied to clipboard

Flag this post as spam?

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


  • Weronika 2 posts 72 karma points
    Jul 06, 2023 @ 12:45
    Weronika
    0

    Umbraco 7 - Generic Picker that recognizes context

    Hello, I am not an expert in Umbraco, so I hope I can phrase my question clearly. It is possible that when I was googling it, I was not aware of the correct wording - please let me know what would be the best way to name my issue in such case.

    I have a Generic Picker (custom property editor added through AppPlugins folder). It is used in two data types: A and B. Then I have some content that uses both of those data types. There is a tab that has four pickers including A and B.

    Recently there was some requirements from the client and one of those pickers should be only visible under some Condition. After development we have discovered a bug - both of those pickers are not visible under Condition.

    I wanted to adjust the Generic Picker code and do something like this:

    if(Condition and Self.PropertyEditorType == A) Do not display

    Is this possible to achieve? I googled it, but nothing that I found worked. I will be very grateful for any direction regarding this matter. Thank you.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Jul 06, 2023 @ 17:09
    Marc Goodson
    1

    Hi Weronika

    Depending which point release of Umbraco 7 you are using, there was introduced in Umbraco 7.4.x a new concept of EditorModel Events

    https://our.umbraco.com/Documentation/Reference/Events/EditorModel-Events/index-v7

    Essentially as an editor 'loads' a page into the backoffice for editing, these events are fired, and they allow you to check certain criteria (you have access to all the data that is about to be edited) and show/hide properties from the Editor or set default values...

    From what you are describing 'I think' that might be what you are describing...

    ... but it's also possible you might be talking about changing the editing options depending on the value selected in a different property editor? eg not before the page is loaded, but dependent on the content being entered?

    this is much trickier to achieve you can sort of discover the state of a property in angularJS via the editorState resource - to give you access to other values, I have done something similar before: https://github.com/marcemarc/OutCrop/blob/master/beta/Our.Umbraco.OutCrop/contentcrop.controller.js#L37 anyway it's fiddily.

    The other way of doing conditional things is instead of having a property, that defines whether Property A or Property B is displayed is to instead have a 'Nested Content' property, which allows two different types of doc types, and you restrict only being able to add one item.

    The editor then clicks to add the Nested Content item, and they have to choose 'which type' of DocType to choose to define their option, one has Property A, the other has Property B, you use the fact they chose a certain Document Type to mean that they have selected a particular choice...

    ... but I'm rather guessing at what you might be doing!

    regards

    Marc

  • Weronika 2 posts 72 karma points
    Jul 14, 2023 @ 05:29
    Weronika
    0

    Hi Marc, Thank you very much for your response. I had to read this a few times, but I feel like I know a lot more than before now, so I appreciate this. Unfortunately none of this solutions was an answer to my problem, but I was able to use a workaround and differentiate the editors by apiEndpoint property. I am very grateful for your answer anyway, as it was very educational.

    Thank you and regards, Weronika

Please Sign in or register to post replies

Write your reply to:

Draft