How to add items to the Document Types context menu.
Posted
by
Vizioz Limited
on Vizioz Umbraco Blog
See other posts from Vizioz Umbraco Blog
or by Vizioz Limited
Published on 2009-07-09T03:49:00.000-07:00
Indexed on
2010/12/06
17:00 UTC
Read the original article
Hit count: 620
Umbraco Extension
|Umbraco Development
See: Codeplex Issue 21623
The "temporary" solution has been to extend the "loadNodeTypes" class, I say temporary because I assume that the core team may well extend the event functionality to the entire menu tree in the future which would be much better and would prevent you from having to complete override the menu items.
This was suggested by Slace on my "is it possible to add an item to the context menu in tree's other than media content" post on the our.umbraco.org site.
There are three things you need to do:
1) Override the loadNodeTypes
using System.Collections.Generic;
using umbraco.interfaces;
using umbraco.BusinessLogic.Actions;
namespace Vizioz.xMind2Umbraco
{
// Note: Remember these menu's might change in future versions of Umbraco
public class loadNodeTypesMenu : umbraco.loadNodeTypes
{
public loadNodeTypesMenu(string application) : base(application) { }
protected override void CreateRootNodeActions(ref List<IAction> actions)
{
actions.Clear();
actions.Add(ActionNew.Instance);
actions.Add(xMindImportAction.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionImport.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionRefresh.Instance);
}
protected override void CreateAllowedActions(ref List<IAction> actions)
{
actions.Clear();
actions.Add(ActionCopy.Instance);
actions.Add(xMindImportAction.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionExport.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionDelete.Instance);
}
}
}
2) Create a new Action to be used on the menu
using umbraco.interfaces;
namespace Vizioz.xMind2Umbraco
{
public class xMindImportAction : IAction
{
#region Implementation of IAction
public static xMindImportAction Instance
{
get { return umbraco.Singleton<xMindImportAction>.Instance; }
}
public char Letter
{
get { return 'p'; }
}
public bool ShowInNotifier
{
get { return true; }
}
public bool CanBePermissionAssigned
{
get { return true; }
}
public string Icon
{
get { return "editor/OPEN.gif"; }
}
public string Alias
{
get { return "Import from xMind"; }
}
public string JsFunctionName
{
get
{
return "openModal('dialogs/xMindImport.aspx?id=' + nodeID,
'Publish Management', 550, 480);";
}
}
public string JsSource
{
get { return string.Empty; }
}
#endregion
}
}
3) Update the UmbracoAppTree table, my case I changed the following:
TreeHandlerType
From: loadNodeTypes
To: loadNodeTypesMenu
TreeHandlerAssembly
From: umbraco
To: Vizioz.xMind2Umbraco
And the result is:
© Vizioz Umbraco Blog or respective owner