Search code examples
.netasp.net-mvcasp.net-mvc-3autofacorchardcms

How to set priority of interface implementation in Orchard?


I'd like to create a custom INavigationProvider in my module for Orchard CMS:

[UsedImplicitly]
LocalizedMainMenuNavigationProvider : INavigationProvider

But it seems that my implementation is not used by the IoC container (AutoFac I think), probably because there is already another module installed that provides an implementation that is used.

How can I enforce Orchard to use my implementation?

Thanks


Solution

  • Menu is built by INavigationManager, which takes an IEnumerable< INavigationProvider > as a parameter. It means that it takes all providers for a given menu name and merges their outputs. And this data is used to render the final menu.

    Also make sure that your class is public - otherwise your implementation won't be registered.

    If I were you I'd rather create a custom implementation of INavigationManager based on the default one (so not to copy/paste all the code). This is the only place where you get all menu items gathered from providers and are able to localize them.

    HTH