Created
June 20, 2018 10:10
-
-
Save biapar/3eaa7870b1474f17da0ff27927625de5 to your computer and use it in GitHub Desktop.
Example Menu Item in Umbraco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Umbraco.Core; | |
using Umbraco.Web; | |
using Umbraco.Web.Trees; | |
//https://github.com/marcemarc/uSpinMeRightRound/blob/master/Solution/tooorangey.uSpinMeRightRound/App_Start/RegisterEvents.cs | |
namespace tooorangey.uSpinMeRightRound.App_Start | |
{ | |
public class RegisterEvents : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
//register custom menu item in the media tree | |
TreeControllerBase.MenuRendering += TreeControllerBase_MenuRendering; | |
} | |
private void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e) | |
{ | |
if (sender.TreeAlias == "media") | |
{ | |
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); | |
var nodeId = e.NodeId; | |
var mediaItem = umbracoHelper.TypedMedia(nodeId); | |
if (mediaItem!= null && mediaItem.DocumentTypeAlias == "Image") | |
{ | |
var rotateMenuItem = new Umbraco.Web.Models.Trees.MenuItem("rotateImage", "Rotate"); | |
rotateMenuItem.Icon = "axis-rotation"; | |
rotateMenuItem.SeperatorBefore = true; | |
rotateMenuItem.AdditionalData.Add("actionView", "/app_plugins/tooorangey.uSpinMeRightRound/selectrotation.html"); | |
e.Menu.Items.Insert(4, rotateMenuItem); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment