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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s