Copied to clipboard

Flag this post as spam?

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


  • Stephan Lonntorp 195 posts 212 karma points
    Jan 04, 2010 @ 09:59
    Stephan Lonntorp
    0

    Adding Unpublish action to context menu in Umbraco 4.1

    When trying to add the unpublish action to the context menu for content nodes using this code:

            public OnContentTreeBeforeNodeRender()
            {
                BaseContentTree.BeforeNodeRender += new BaseTree.BeforeNodeRenderEventHandler(BaseContentTree_BeforeNodeRender);
            }

            void BaseContentTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
            {

                if (node.NodeType.Equals("content", StringComparison.InvariantCultureIgnoreCase))
                {
                    try
                    {
                        if (node.Menu != null)
                        {
                            int index = node.Menu.FindIndex(a => a.Alias.Equals("publish", StringComparison.InvariantCultureIgnoreCase)) + 1;
                            node.Menu.Insert(index, ActionUnPublish.Instance);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Add(LogTypes.Error, int.Parse(node.NodeID), ex.ToString());
                    }
                }
            }

    The event is triggered, and when stepping through code, the action is even added to the context menu. However, no item appears in the menu.

     

    Any ideas?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jan 04, 2010 @ 12:57
    Aaron Powell
    0

    it'd be easier to just overload the content tree and add it that way. In fact I think it's the recommended way to modify the tree

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 04, 2010 @ 13:15
    Stephan Lonntorp
    0

    @slace You got any examples or pointers on where I can find some?

  • Richard Soeteman 4054 posts 12927 karma points MVP 2x
    Jan 04, 2010 @ 13:23
    Richard Soeteman
    0

    @slace, this example is adding an item to the existing Umbraco content tree, how can you overload that?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 04, 2010 @ 13:38
    Dirk De Grave
    0

    @Richard: you'd override the CreateRootNodeActions() or CreateAllowedActions() method, or if you wish to specify specific actions on specific content nodes, you'd override the Render() method...

    @Stephan: bit puzzled as the unpublish action should be included by default? (for published content nodes that is)...

    @slace, @Stephan: I'd still prefer Stephan's method in case you'd like to add the unpublish action for (a) specific node(s)

    Cheers,

    /Dirk

     

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 04, 2010 @ 13:46
    Stephan Lonntorp
    0

    Actually, it's Richard's method :)

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 04, 2010 @ 13:55
    Stephan Lonntorp
    0

    Oh, and doing like it said here, http://our.umbraco.org/wiki/reference/backoffice-apis/tree-api---to-create-custom-treesapplications, only results in a non-working content tree.

    When using the BeforeNodeRenderEventHandler results in javascript errors, when the JsFunctionName property is set to anything but an empty string.

  • Richard Soeteman 4054 posts 12927 karma points MVP 2x
    Jan 04, 2010 @ 13:58
    Richard Soeteman
    0

    @Dirk, where can you configure that (for the existing umbraco config tree)? I think you can't besides hacking the database and register the correct type?

      

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 04, 2010 @ 14:44
    Stephan Lonntorp
    0

    @Dirk The UnPublish Action isn't available in the context menu, and there's no JS-method for it in the AppActions registered, this is probably du to the fact that it's implemented with a postback button on the editpage. Dunno if this is by design, or just not implemented.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies