Customise File Manager Right-Click menu

Vote:
 

Hi,

I'm trying to add an item to the context menu when right-clicking on a file in the file manager but I'm having issues getting a hold of the current context menu object. I've hooked into PageBase.PageSetup and also ActionWindow.PageSetup events to get the context menu but it is always null which leads me to believe I'm barking up the wrong tree.

Can anyone point me in the right direction?

 

Thank you

#69716
Apr 03, 2013 14:33
Vote:
 

This post may help (I have not tried it but you might be able to adapt the approach for the file manager):

http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2011/6/How-to-change-context-menu-in-the-edit-mode-tree-view/ 

#69718
Apr 03, 2013 14:56
Vote:
 

Hi David,

 

Thanks, thats actually the approach I've used. The reflection isn't necessary as ActionWindow inherits pagebase and thus exposes a ContextMenu property - problem is its always null in the PageSetup event handler. I'm guessing I'm trying in the wrong time in the lifecycle or the ContextMenu is possibly set on a PlugIn contained within the ActionWindow object?

#69723
Apr 03, 2013 16:21
Vote:
 

You can try hooking in on PreRender using an init module. (untested) Example below:

[InitializableModule]
[ModuleDependency((typeof(EPiServer.Web.InitializationModule)))]
public class AddContextMenu : IInitializableHttpModule
{
    private static bool _loaded = false;

    public void InitializeHttpEvents(System.Web.HttpApplication application)
    {
        application.PreRequestHandlerExecute += context_PreRequestHandlerExecute;
    }

    private void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        //Get the Request handler from the Context
        HttpContext context = ((HttpApplication)sender).Context;

        //Check if the request handler is a PageBase object
        if (context.Handler is EPiServer.PageBase)
        {
            PageBase pageBase = (PageBase)context.Handler;
            pageBase.PreRender += page_PreRender;
        }
    }

    private void page_PreRender(object sender, EventArgs e)
    {
        if (sender is ActionWindow)
        {
            // Code to hook into menu here

        }
    }

    public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
    {
        //throw new NotImplementedException();
    }

    public void Preload(string[] parameters)
    {
        throw new NotImplementedException();
    }

    public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
    {
        //throw new NotImplementedException();
    }
}

    

 

 

#69724
Apr 03, 2013 16:33
Vote:
 

Thanks again David, unfortunately no luck! I definitely think I'm going about this the wrong way and assume the context menu when right-clicking on a file is actually being set somewhere in EPiServer.UI.Hosting.VirtualPathFileManager, just can't see where. I think I'm going to try a different approach that doesn't involve affecting this context menu.

#69745
Apr 04, 2013 12:09
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.