Copied to clipboard

Flag this post as spam?

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


  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 10:58
    Jason Evans
    0

    How to display the "Create" dialog from code, rather then the content tree?

    How can I display the "Create" dialog window (e.g. "Create Member" when right-clicking on a content node in the content tree) from my own code?

    My idea is that I'd like to remove the right-click "Create" option from a content node, and have my own "Create" button elsewhere. Thus when the user clicks on my "Create" button, I'd like to execute the same code that the original "Create" functionality would called.

  • Sean Mooney 131 posts 158 karma points c-trib
    Oct 23, 2012 @ 14:29
    Sean Mooney
    0

    you should be able to use the following javascript:

    UmbClientMgr.openModalWindow('/umbraco/create.aspx?nodeId=init&nodeType=initmember&nodeName=Members&rnd='+ Umbraco.Utils.generateRandom(), UmbClientMgr.uiKeys()['actions_create'], true, 480, 380);

     

  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 14:53
    Jason Evans
    0

    Thanks, that worked great :)

  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 17:08
    Jason Evans
    0

    Another quick question - how can I stop the openModalWinodw() from going to the EditMember.aspx page hwne it has finished with the "Create" page?

    I can create a new member group, using the dialog which is now called via my code. However, open creating a new member group, the site tries to redirect to EditMemberGroup.aspx, but I don't want it to do that. Can I override this behaviour?

  • Sean Mooney 131 posts 158 karma points c-trib
    Oct 23, 2012 @ 17:18
    Sean Mooney
    0

    I belive you would have to create your own page (ie. CustomCreateMember.aspx) that does the member creation (via the API's). then use the same javascript to load the new page:

    UmbClientMgr.openModalWindow('/umbraco/CustomCreateMember.aspx&rnd='+Umbraco.Utils.generateRandom(),UmbClientMgr.uiKeys()['actions_create'],true,480,380);

    I would also take a look at the /umbraco/create.aspx page and be sure to use the same Masterpage

  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 17:45
    Jason Evans
    0

    Turns out I've just found a solution.

    I have coped the "MemberGroupTasks" class from the Umbraco source and compiled a new version of it in my own code (i.e. the ReturnUrl property of this class now points to wherever I want it to go). To use this new version of MemberGroupTasks, I edit the ui.xml file and set thigns like:

    <create assembly="MyAssemblyName" type="Tasks.MemberGroupTasks" />

    So when I now create a new memebr group, my code is executed and not Umbraco's MemberGroupTasks.

    Thanks for the response though, much appreciated :)

  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 18:20
    Jason Evans
    0

    Right, one final (I hope) question:

    There is still a "Create" option being displayed when I right-click on the "Member Group" content node item in the tree. How can I remove this "Create" item from the menu?

    I did try removing the entire ui.xml config for this:

     

    <nodeType alias="initmemberGroup">
        <header>membergroup</header>
        <usercontrol>/create/simple.ascx</usercontrol>
        <tasks>
          <create assembly="Pathfinder.Web.BusinessLogic" type="Tasks.MemberGroupTasks" />
        </tasks>
      </nodeType>

    but the "Create" menu item still appears. Can you suggest how I can remove this please?

     

  • Sean Mooney 131 posts 158 karma points c-trib
    Oct 23, 2012 @ 18:30
    Sean Mooney
    0

    You should be able to "hook" into the AfterNodeRender event of the BaseTree for the member section and remove the create option.

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events

    see example 3:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/event-examples

    something like this:

    node.Menu.Remove(umbraco.BusinessLogic.Actions.ActionNew.Instance)

     

  • Jason Evans 50 posts 71 karma points
    Oct 23, 2012 @ 20:02
    Jason Evans
    0

    Cheers for your help, much appreciated.

    I will have a crack at this tomorrow, using your suggested ideas with the hooking of events.

Please Sign in or register to post replies

Write your reply to:

Draft