Copied to clipboard

Flag this post as spam?

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


  • Mikael Mørup 297 posts 326 karma points
    Dec 14, 2009 @ 14:53
    Mikael Mørup
    0

    VB code for adding context menu

    I am planning to add a context menu to some nodes in the content tree.

    I found the sample code at Richard Soeteman's site, and as far as i can see it should be fairly straight forward.

    But this is new territory for me, so i was wondering if anybody has some sample code in VB.net that does this  ?

    Thanks

    Mikael

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Dec 14, 2009 @ 15:47
    Richard Soeteman
    1

    Hi Mikael,

    I've used this online converter to convert the example to VB.Net. Hope it helps you,

    Cheers,

    Richard

    Imports System 
    Imports umbraco.BusinessLogic
    Imports umbraco.cms.presentation.Trees
    Imports umbraco.interfaces
    Namespace UnpublishAction 
        ''' <summary>
        ''' Add unpublish to the menu item
        ''' </summary>
        Public Class AddUnpublishActionEvent
            Inherits ApplicationBase
            Public Sub New()
                AddHandler BaseContentTree.BeforeNodeRender, AddressOf BaseTree_BeforeNodeRender
            End Sub
           
            ''' <summary>
            ''' Before a menu item gets rendered we will add the unpublish action if the document is published
            ''' </summary>
            Private Sub BaseTree_BeforeNodeRender(ByRef sender As XmlTree, ByRef node As XmlTreeNode, ByVal e As EventArgs)
                '''Only unpublish when published
                '''RS: ADDED node.Menu!= null check
                If node.Menu IsNot Nothing AndAlso Not node.NotPublished.GetValueOrDefault(True) Then
                    'Find the publish action and add 1 for the index
                    Dim index As Integer = node.Menu.FindIndex(Function(ByVal a As IAction) a.[Alias] = "publish") + 1
                   
                    'Insert unpublish action
                    node.Menu.Insert(index, UnpublishAction.Instance)
                End If
            End Sub
        End Class
    End Namespace
Please Sign in or register to post replies

Write your reply to:

Draft