Developer forum

Forum » Rapido » Mega menu only for products

Mega menu only for products

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

If I want to display the mega menu only for the products page, what would be a good approach for this?

In this case it does not make sense to have the mega menu look on other pages than the products page. 

Maybe creating a new XSLT and replacing the Block that holds the navigation?

Regards / Aki


Replies

 
Nicolai Pedersen
Reply

Question not understood... Can you ellaborate?

 
Aki Ruuskanen
Aki Ruuskanen
Reply

There is a setting in Rapido where you can choose how to render the top navigation. You can choose between dropdowns or a mega menu.

I would like to have the mega menu only for one page. The page that renders product groups. 

mega-menu.png
 
Nicolai Pedersen
Reply
This post has been marked as an answer

Ah, for one page navigation item... And not page. Now I understand.

You cannot currently without customisation. So yes, a custom navigation block is the way to go. Also remember that you can use Razor templates instead. Below an example that creates a megamenu for bootstrap templates:

@{
                        var navigationSettingsMain = new Dynamicweb.Frontend.Navigation.NavigationSettings()
                        {
                            StartLevel = 1,
                            StopLevel = 3,
                            ExpandMode = Dynamicweb.Frontend.Navigation.ExpandMode.All
                        };

                        NavigationTreeViewModel navigation = GetNavigation(navigationSettingsMain);

                    }
                    <ul class="collapse navbar-collapse navbar-nav" id="navbarNavAltMarkup">
                        @foreach (NavigationTreeNodeViewModel node in navigation.Nodes)
                        {
                            string classes = string.Empty;
                            if (node.InPath)
                            {
                                classes = "current-menu-item";
                            }
                            <li class="nav-item dropdown megamenu-li @classes">

                                @if (node.Nodes.Any())
                                {
                                    int megaMenuSetting_MaxColumns = 6;
                                    bool megaMenuSetting_ShowParagraph = true;
                                    bool megaMenuSetting_RepeatMasterWhenNoChildren = true;
                                    int megaMenuColumns = 1;
                                    <a href="@node.Link" class="text-reset dropdown-toggle" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">@node.Name</a>
                                    <div class="dropdown-menu megamenu rounded-0 border-bottom pb-3 shadow" aria-labelledby="navbarDropdown">
                                        <div class="row">
                                            @foreach (var subnode in node.Nodes)
                                            {
                                                if (megaMenuColumns > megaMenuSetting_MaxColumns) { break; } //Never show more than 5 columns
                                                <div class="col">

                                                    <a href="@subnode.Link" class="text-decoration-none">
                                                        <h5 class="text-uppercase font-size-sm text-dark border-bottom pb-2">@subnode.Name</h5>
                                                    </a>
                                                    @if (subnode.Nodes.Any())
                                                    {
                                                        foreach (var subsubnode in subnode.Nodes)
                                                        {
                                                            <a class="d-block w-100 text-nowrap py-2 m-n2 px-2 font-size-sm text-decoration-none text-secondary" href="@subsubnode.Link">@subsubnode.Name</a>
                                                        }
                                                    }
                                                    else if (megaMenuSetting_RepeatMasterWhenNoChildren)
                                                    {
                                                        <a class="d-block w-100 text-nowrap py-2 m-n2 px-2 font-size-sm text-decoration-none text-secondary" href="@subnode.Link">@subnode.Name</a>
                                                    }
                                                </div>
                                                megaMenuColumns++;
                                            }
                                            @if (megaMenuSetting_ShowParagraph)
                                            {
                                                <div class="col">
                                                    <h5>Paragraph</h5>
                                                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
                                                    <img src="/Admin/Public/GetImage.ashx?Image=%2fFiles%2fImages%2fBikes%2fmtb1.jpg&Format=webp&Width=250" alt="..." style="width: 100%;">
                                                </div>
                                            }
                                        </div>
                                    </div>
                                }
                                else
                                {
                                    <a href="@node.Link" class="text-reset">@node.Name</a>
                                }
                            </li>
                        }
Votes for this answer: 1
 
Aki Ruuskanen
Aki Ruuskanen
Reply

Ah, right. Forgot about that you can do the navigation with razor. Really nice.

XSLT gives me migraine. :)

Thanks for the input.

/Aki

 

You must be logged in to post in the forum