This project is read-only.

Customizing Admin side menu

Topics: Administration, Customizing Orchard
Nov 18, 2011 at 3:39 PM

I'm somewhat familiar with how to customize the Admin side menu within a module by creating AdminMenu.cs and implementing my own INavigationProvider. However, I'm not writing my own module at this time. What I'm attempting to do is customize the display order and visibility of the Admin menu items (if possible, with custom code in TheAdmin theme). Is this possible? Do I still need to implement my own INavigationProvider, and if so, where does the AdminMenu.cs file go within TheAdmin theme (seems like that's not correct that it would go in there, and that's really what is confusing me right now).

The purpose isn't permissions; it's cosmetic (for usability purposes).

Thanks so much for any guidance.



Nov 18, 2011 at 4:38 PM

I advise creating a new module to put this in, you can then specify dependencies or priority to make sure it runs after the providers you're trying to modify. I quite often create a small custom module to lump together a few minor cosmetic things for my own purpose or for a particular site.

Nov 21, 2011 at 7:40 PM
Edited Nov 21, 2011 at 7:42 PM

So I gave this a try w/ the following:


using System.Linq;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.UI.Navigation;
using Orchard.Utility.Extensions;
using Szmyd.Orchard.Modules.Menu;

namespace MyCompany.AdminMenu
    public class AdminMenu : INavigationProvider

        public Localizer T { get; set; }
        public string MenuName { get { return "admin"; } }

        public void GetNavigation(NavigationBuilder builder) {
            builder.AddImageSet("tags").Add(T("Tags"), "118");


This is my first module, so I'm not sure it's this code that's the problem. I created the module using codegen and it build successfully. 
I recycled my AppPool, and I'm stil not getting the "Tags" menu item to render in a different position.
Anything obvious that I'm doing wrong?

(Orchard version: 1.3.9) 
Nov 21, 2011 at 7:41 PM

Also, I'm not sure how to "specificy dependencies or priority to make sure it runs after the providers...".  

Nov 21, 2011 at 8:14 PM

Edit the Module.txt in the root directory of your module.

You can add a dependency line as follows:

Dependencies: Navigaion

Also, you probably don't need to suppress the dependency, yours will then run after it anyway and just update the data for that menu.

Have you remembered to actually enable the module in admin?

Nov 23, 2011 at 2:29 PM
Edited Nov 23, 2011 at 2:34 PM

Ha, yes I did actually enable the module in the admin. But thanks for reminding me. I DO often forget that. :-)

Adding the Dependency to the Module.txt manifest did the trick. Thanks a lot!

Nov 25, 2011 at 6:21 PM

Ok, I have a quick follow up to this.

So I'm trying to override the positioning of (for example) the Tags nav item. So adding menu items for my own custom modules works. I created a HelloWorld module and added an AdminMenu.cs to it. The "Hello World" navigation item I created rendered as expected. What I can't figure out is how to override an existing menu item that is controlled in another module (for example, Orchard.Tags) without actually modifying the code in Orchard.Tags project. (or is that what I'm supposed to do since it isn't core?) So within my HelloWorld custom module, will code that I write in its AdminMenu.cs override menu code in another module?



Nov 25, 2011 at 6:42 PM

I thought you said adding the dependency worked?

Nov 25, 2011 at 6:44 PM

Note: to change the position of Tags, you probably also need a dependency on the Tags module (so Orchard knows to run your code after the Tags module). Or, you can specify Priority: in your module to set it at a higher or lower priority than tags (you'll have to experiment with this, I don't know what priority to set it to).

Nov 25, 2011 at 6:58 PM

Yes, adding the dependency worked for my HelloWorld nav item (sorry, I reread this thread and can see I didn't communicate that very well). And so that's what I was responding to. That worked fine. It's when I tried to tweak an existing nav item (in this case, Tags) that I ran into trouble.

Priority (and Tags dependency) might be what I'm missing. Sorry for hassle on this one

Nov 25, 2011 at 7:06 PM

No problem.

If all else fails, you can always use OrchardSuppressDependency to suppress the AdminMenu.cs from Tags and implement your own (as you were doing in your original code, except you suppressed the one from Navigation, not from Tags)

Nov 25, 2011 at 7:25 PM

Ok. There we go. Now it really does work. hahaha...

Apparently didn't need to set Priority. Adding Tags dependency was what I needed. Going through this exercise cleared up alot for me. I had initially thought that I was including a dependency on Navigation because I was updating---well---navigation :-) But I would need that if I were trying to do something to override the Navigation module itself. The Navigation module doesn't control the Tags nav item in Admin menu, the Tags module does. So in order to override the placement of, for example, Widgets menu item in admin, I need to actually override what is going on in Widgets AdminMenu.cs. Nothing to do with Navigation module per se.

You've been very helpful last few days, randompete. Really appreciate it.

Nov 25, 2011 at 10:34 PM

Dependencies are mainly declared for two reasons; a) to ensure that your feature can only be enabled if the dependant feature is enabled. In this case it didn't matter because INavigationProvider is part of core which will always be enabled anyway. And b) to ensure Orchard knows the correct injection order based on feature inheritance - which is what you needed here.

If you simply need access to a particular service or interface you only actually have to add a project reference; it'll *work*, but you risk getting errors if the feature isn't installed/enabled, so you also declare the dependency in Module.txt (but it's easy to forget sometimes!) Anyway it looks like you understand the inheritance order business now, it's something I think not everyone is aware of.