Copied to clipboard

Flag this post as spam?

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


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Aug 23, 2016 @ 15:21
    Michaël Vanbrabandt
    0

    Open umbraco standard dialogs from a custom plugin

    Hi,

    I am working on a new plugin which is a new tab under the content section.

    I would like to be able to open the Create node dialog from within my plugin controller.

    Is this possible?

    Like for example I will have a button to add a new root node, so if I click on it, it must open the dialog with the allowed root nodes.

    I will also have buttons to create child nodes, so for an existing content node ( using its id ) if I then click on the add child node it must open the Create dialog with now the available child nodes for the given node id.

    Can anyone help me in the right direction?

    /Michaël

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 23, 2016 @ 15:47
    Dennis Aaen
    0

    Hi Michaêl,

    Have you seen this documentation?

    https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.dialogService

    Hope this helps,

    /Dennis

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Aug 24, 2016 @ 07:38
    Michaël Vanbrabandt
    0

    Hi Dennis,

    yes I have seen this documentation but I think I need more then this?

    What do I need to inject to get the same result as clicking on the 3 dots next to the Content in the content section?

    I see that its calling a function options(tree.root, $event) so I need to have the same behaviour but now on a custom button in my plugin.

    /Michaël

  • Ian 178 posts 752 karma points
    Aug 23, 2016 @ 18:13
    Ian
    0

    Caveat this is untested:

    As the create dialog is more than just than a simple dialog you might create yourself it MIGHT be worth trying to imitate the behavior from treeOptionsClick handler in /umbraco/js/umbraco.services.js which then leads on to navigationService.showMenu

    As a result code in your controller might look like this (wrapped in your own function with your own trigger added of course)

     appState.setMenuState("currentNode", args.node);
     navigationService.showMenu(ev, args);
    

    In the genuine implementation there are a bunch of properties within args, but it looks like the only important ones for the showMenu function are the node property which, if you can grab within your controller you can mock into an args object for use in this code, and 'skipDefault' which should be false if you want to show the create menu in the dialog.

    This would require you inject both appState and navigationService into your controller.

Please Sign in or register to post replies

Write your reply to:

Draft