Copied to clipboard

Flag this post as spam?

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


  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 06, 2014 @ 12:08
    Lee Kelleher
    0

    How to get current ID within v7 Property Editor

    Is there an established way to get a content/media item's ID from within a property-editor? (v7.0.3+)

    Looking from the options, I can either:

    • Get the URL's hash fragment and parse out the ID from it
    • Use the HTML DOM to find the value from the read-only "ID" property field (which doesn't have a specific HTML id)

    Any other options?

    Thanks,
    - Lee

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Feb 06, 2014 @ 12:19
    Tim
    0

    I think there's a service for this, I asked Per about it a while ago. I'll have a look and see if I can find the email......

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Feb 06, 2014 @ 12:21
    Tim
    1

    Apparently it's in the editorState? Not sure how you get to that though, I haven't had time to get any further on it.......

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 06, 2014 @ 12:23
    Lee Kelleher
    0

    Thanks Tim, much appreciated. I'll have a dig around.

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Feb 06, 2014 @ 12:33
    Arnold Visser
    115

    You can use '$routeParams':

    angular.module("umbraco").controller("Name", function ($scope,$routeParams) {
    
        var nodeId = $routeParams.id;
    
    });
    

    editorState also very interesting to get a lot of the information about the node like the alias:

    angular.module("umbraco").controller(“Name”, function ($scope, editorState) {
    
        if(editorState.current.contentTypeAlias != “nodeTypeAlias”) {
            }
    
    });
    
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 06, 2014 @ 12:34
    Lee Kelleher
    0

    oops... just noticed that I cross-posted with Arnold (removing my message) :-)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 06, 2014 @ 12:37
    Lee Kelleher
    5

    For reference: I was ultimately after the parent ID, so I am using editorState.current.parentId to do that.

  • lucuma 261 posts 563 karma points
    May 08, 2014 @ 13:44
    lucuma
    6

    Since nobody actually posted this, the actual id of the current node on the editorState is:

    editorState.current.id
    

    I'm wondering now that umbraco is using some cachebusting (is nice on prod) to load the javascript if there is a way to disable that as it makes it impossible to put breakpoints in the chrome console. I had to console.log to get the id.

  • Openfield Creative 62 posts 222 karma points
    Mar 25, 2015 @ 22:27
    Openfield Creative
    0

    Sorry all, posted here even though i meant to start a new thread.

  • Jonathan Roberts 409 posts 1063 karma points
    Jul 13, 2018 @ 11:12
    Jonathan Roberts
    0

    If you select the node then all this is relevant - but if you have selected a node, for example ID 1202.

    Then you right click on a different node in the tree - you still get the selected id of 1202.

    How can you get the ID of the node that you have just right clicked on?

    Jon

Please Sign in or register to post replies

Write your reply to:

Draft