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
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
Hi Mikael,
I've used this online converter to convert the example to VB.Net. Hope it helps you,
Cheers,
Richard
is working on a reply...