Mega menu in Version 5.1

Posted by Community Admin on 04-Aug-2018 15:17

Mega menu in Version 5.1

All Replies

Posted by Community Admin on 24-Sep-2012 00:00

We created a custom mega menu in our old site on Sitefinity version 3.7.2096.220:1 and want to convert it for version 5.1.

Here's the partial code. Please let me know if this could be converted to 5.1.

Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager(); 
        foreach (Telerik.Cms.ICmsPage page in cmsManager.GetPages())
       
            if (page.PageType == CmsPageType.Group)
           
                SiteMapNode node = SiteMap.Provider.FindSiteMapNodeFromKey(page.ID.ToString());

                if (node != null && SiteMap.CurrentNode != null)
                    if (SiteMap.CurrentNode.IsDescendantOf(node))
                        startingNode = node;
           
       

Are there any examples of mega menu?
Thanks,
SG.

Posted by Community Admin on 25-Sep-2012 00:00

The easiest way I’ve found to implement a ‘mega’ menu, is to create a user-control that handles the ‘ItemDataBound’ event of a SiteMapNavigationMenu (i.e. a wrapped RadMenu) and specify it as the 'Design-Settings->Custom-Template-Path" option, when setting the properties of a standard navigation control with the page/template editor.

Then, when the standard navigation control hits the menu level settings you specified (typically that would be level-1) it hands off the ItemDataBound event to the usercontrol you specified as the Custom-Template, from where you get to take full control.

In the ItemDataBound event handler, you can make choices to load a menu template (e.g. a MegaMenu template) or load standard submenu items.

Of course, it's not a solution for every situation, but seems to apply for the typical MegaMenu applications.

MegaMenu.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MegaMenu.ascx.cs" Inherits="MyTemplates.MegaMenu" %>
 
<%@ Register tagprefix="sf" namespace="Telerik.Sitefinity.Web.UI" assembly="Telerik.Sitefinity" %>
<%@ Register tagprefix="sf" namespace="Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations" assembly="Telerik.Sitefinity" %>
<%@ Register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
 
<sf:SiteMapNavigationMenu id="SiteMapNavigationMenu1" runat="server" skin="Black" />

MegaMenu.ascx.cs
using System;
using System.Linq;
using System.Web.UI;
using Telerik.Web.UI;
using Telerik.Sitefinity.Web.UI.Templates;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web;
 
namespace MyTemplates
    public partial class MegaMenu : System.Web.UI.UserControl
    
        protected void Page_Load(object sender, EventArgs e)
        
            // Add the Delegate for the ItemDataBound event
            this.SiteMapNavigationMenu1.ItemDataBound += new Telerik.Web.UI.RadMenuEventHandler(SiteMapNavigationMenu1_ItemDataBound);
        
 
        // Handle the ItemDataBound event
        protected void SiteMapNavigationMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
        
            // This is the menu item that fired the event.
            RadMenuItem item = e.Item;
 
            // Now we can decide between:
            // 1. Insert a 'Mega' template at this point (load and/or construct it)
            // 2. Build the standard sub-menu tree (recursively walk the item's tree)
            // 3. Do some other weird stuff
        
 
    

Posted by Community Admin on 29-Apr-2014 00:00

can u provide sitefinity  megamenu complete code step-by-step.

Posted by Community Admin on 01-May-2014 00:00

Hello,

You can follow this blog post which shows how to create a mega menu in Sitefinity step by step. You can also consider our Pages API documentation, for how to query pages.

Regards,
Nikola Zagorchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed