Fire package controller function after clicking custom menu item
Hi all,
I have a BootStrapper class which adds a new menu item on the members menulist.
I was wondering if its possible to fire a function inside my controller after hitting this menu item, or do we first need to show a dialog which then calls the controller function after hitting another button inside the dialog?
public class PackageApplicationEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
TreeControllerBase.MenuRendering += Package_MenuRendering;
}
private void Package_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
{
// If not rendering menu for the document types, return
if (sender.TreeAlias != "member") return;
var menuItem = new Umbraco.Web.Models.Trees.MenuItem("package", "Package Item");
menuItem.Icon = "client";
// Append someting to fire controller function inside
// my App_Plugins/Package folder after hitting this menu item
menuItem.SeperatorBefore = true;
e.Menu.Items.Insert(e.Menu.Items.Count, menuItem);
}
}
Fire package controller function after clicking custom menu item
Hi all,
I have a BootStrapper class which adds a new menu item on the members menulist.
I was wondering if its possible to fire a function inside my controller after hitting this menu item, or do we first need to show a dialog which then calls the controller function after hitting another button inside the dialog?
/Michaël
Hi Michaël,
I don't think this is possible. But I think you can still execute javascript from the menu. There is a ExecuteLegacyJs function on the menu item : https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web/Models/Trees/MenuItem.cs#L125
Dave
Hi Dave,
thanks for the intel, I will then launch a new view to do the task.
/Michaël
is working on a reply...