Creating a MenuProvider in EPiServer CMS

EPiServer CMS 6 made it is possible to extend the main navigation that is being displayed in the user interface. Extending the navigation in EPiServer goes under the name Menu Providers and is one of the features in the OnlineCenter concept.

The code below is an example on how a menu provider could be implemented.

[SearchProvider]
public class MySearchProvider : ISearchProvider
{
    public string Area
    {
        get { return “My Area”; }
    }

    public string Category
    {
        get { return “Content Types”; }
    }

    public IEnumerable<SearchResult> Search(Query query)
    {
        var contentTypeRepo =
            ServiceLocator.Current.GetInstance<IContentTypeRepository>();

        return contentTypeRepo.List()
            .Where(a => a.Name.ToLower().Contains(query.SearchQuery))
            .Select(a => new SearchResult(“”, a.DisplayName, a.Description));
    }
}

Advertisements