Copied to clipboard

Flag this post as spam?

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


  • Asif Malik 203 posts 339 karma points
    Mar 03, 2018 @ 18:12
    Asif Malik
    0

    Nested content

    Hi, I have created a custom data type that allows editors to configure styling options for the Document Type it is a property on. This Document Type is then being used within a Nested Content item. This is all working correctly, ie - a content editor adds content via the backoffice they can choose from a list of styling options. The chosen option are then applied to the front end view. This data type is being used on a number of Document Types, what i would like to do is set the default selected options based on the Document Type (not the pages document type, the nested contents document type).

    My JS contoller for the data type fires correctly (ie when the nested content is opened) however i cant figure out how to get the related doc types information ... any ideas ?

  • Rune Hem Strand 147 posts 911 karma points hq c-trib
    Mar 03, 2018 @ 19:44
    Rune Hem Strand
    0

    Hi Asif

    You should be able to get what you want with https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.editorState

    Inject into your controller and try doing console.log(editorState.getCurrent()); to see all the glorious info available :)

    /Rune

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2018 @ 12:04
    Asif Malik
    0

    Hi Rune and thanks for your help .... i could have sworn i checked that ... anyway thankyou. I have managed to loop through all the properties and can create an object array of my custom data type 'stylingOptions' - perfect.

    Now i am trying to work out which one is currently in view, the property has a key but this doesn't match anything in the $scope for the data type. Any ideas

    Hope that makes sense any any help in pointing me in the right direction is appreciated :)

    Thanks PS is there any difference between editorState.getCurrent() and editorState.current

  • Rune Hem Strand 147 posts 911 karma points hq c-trib
    Mar 04, 2018 @ 12:20
    Rune Hem Strand
    0

    Not sure I follow. Do you mean which Nested Content item is open?

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2018 @ 13:26
    Asif Malik
    0

    Correct.

    So right now using the editorState i have created an array of each instance of stylingOptions (this is the propertyAlias). This is on a number of nested content items, and can actually be nested within nested content. So the list for example contains 12 entries relating to stylingOptions.

    The array is made up of an object which has the following fields 'stylingOptions', 'ncContentTypeAlias' and 'key'.

    Now i go and open one of the Nested Content items, my JS runs so i have my array of all stylingOptions instances, i want to find out what has just been opened so i can retrieve the ncContentTypeAlias from my array.

    Hope that makes more sense. and thanks for the quick response

  • Rune Hem Strand 147 posts 911 karma points hq c-trib
    Mar 04, 2018 @ 16:03
    Rune Hem Strand
    0

    Ouch, that is a tricky one... I don't see any obvious solution to that. Show/hide NC items is all handled in the NC edit view by checking realCurrentNode. It exists on a parent scope somewhere but I don't know of a good way to get that :/

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2018 @ 17:05
    Asif Malik
    0

    Thanks for your help ... will see if i can do it another way .... if anyone else can think of another way to get it, please let me know

Please Sign in or register to post replies

Write your reply to:

Draft