Copied to clipboard

Flag this post as spam?

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

  • Matthieu Nelmes 102 posts 385 karma points
    Nov 10, 2015 @ 16:48
    Matthieu Nelmes

    Creating a Custom Property Editor - Get current content page Id?

    I've created custom sections, list-views, all pulling in data from custom database tables.

    For my next trick, I'm looking to create a Property editor that pulls in/saves data to a custom table with the associated page Id.

    I'm just not sure how to pass the current page id to my Angular functions in order to call the correct data. Forgive me for being such an Angular newb. I'm slowly getting there!

    So, for example I'm envisioning having to specify an angular resource such as:

        .factory("bookingResource", function ($http) {
            return {
                getItemsById: function (id) {
                    return $http.get("backoffice/BookingsAdmin/BookingsApi/GetItemsById?id=" + id);

    So this will call the appropriate backoffice APIController. I just can't for the life of me think of how to pass the current page Id there?

  • Nicholas Westby 2043 posts 7020 karma points c-trib
    Nov 10, 2015 @ 17:26
    Nicholas Westby

    It seems like the Umbraco codebase does that by looking at $ (and that comes from the URL, I believe):

    EDIT: Since this is the accepted answer, I should note that Tim's answer below is probably better. That is, he says to use this instead:

    I suspect that is better because it is more likely to work in something like the dialog that appears when you click "Edit" under a picked node in a multinode treepicker.

  • Matthieu Nelmes 102 posts 385 karma points
    Nov 10, 2015 @ 18:20
    Matthieu Nelmes

    Of course!!! Fantastic!

    Although I think the section you've referenced refers to the starting NodeId of a content picker. But still, there should be something here I can use.


  • Tim Miller 32 posts 252 karma points
    Nov 10, 2015 @ 17:55
    Tim Miller

    See this thread:

    In short, this should probably do the trick for you though:

    Don't forget to include editorState in your call.

  • Nicholas Westby 2043 posts 7020 karma points c-trib
    Nov 10, 2015 @ 18:41
    Nicholas Westby

    Interesting. I wonder if is preferable to $ I think it might be, such as in the case that a page is opened for editing in a dialog (i.e., the URL wouldn't necessarily change, but the editor state for that dialog may). This is possible, for example, from the multinode treepicker when the experiment edit mode is enabled.

    Here is some documentation on editorState:

  • Matthieu Nelmes 102 posts 385 karma points
    Nov 11, 2015 @ 16:51
    Matthieu Nelmes

    Just to report back,

    did the trick!

Please Sign in or register to post replies

Write your reply to: