Copied to clipboard

Flag this post as spam?

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


  • keilo 568 posts 1023 karma points
    Apr 12, 2014 @ 20:03
    keilo
    0

    How to get parent URL or property within v7 Property Editor

    I understand that one can get parentId by using editorState.current.parentId

    My questions is how can I get the parent URL (or parent property, like parent.imageurl in parent's doctype)?

    I have tried my luck with the documentation on belle wihout any luck and cant seem to find any reference on how to get parent properties or URL. 

    Any Umbraco 7 experts can chip in any ideas?

    Basically I would like to get the image (or url of page) from the parent and show this within the property view.

    Would appreciate any assistance or pointers greatly.

    cheers

    keil0

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 12, 2014 @ 20:50
    Jan Skovgaard
    0

    Hi Keilo

    I just had a look at the belle documentation as well and I'm thinking that perhaps you could use the getPath method?

    If you know the current id it should be possible to find the current id in the string returned and then choose the id just before the current one?

    I don't have an example on how to do it...just thought that it should be possible.

    But I would love to know if there is a better way as well :)

    /Jan

  • keilo 568 posts 1023 karma points
    Apr 13, 2014 @ 14:53
    keilo
    100

    Hi Jan

    Thank you for your reply and pointer.

    I couldnt use the treeservice as it did not initialize. Even then I can only find reference in JS folder with usage like getPath(..).join() so it didnt look very promising.

    I would be interested to know though how one can use the treeservice getPath, so I can keep it as a reference.

    Meanwhile, while I was digging more inside the documentation and JS folder, I managed to find contentResource.getNiceUrl(id)

    and used like this to get parent.url:

    contentResource.getNiceUrl(editorState.current.parentId)

      .then(function(url) {

       alert("Parent document URL:" + url);

      });

    That being said, I still do not know how can I get a property from the parent node.

    I can get the published date like

    contentResource.getById(editorState.current.parentId)

      .then(function(content) {

     alert(  content.publishDate)

      });

    but cant seem to find the function for retrieving another property, like uploaded image path (from upload property).

    cheers,

    keil0

Please Sign in or register to post replies

Write your reply to:

Draft