custom menu in 4.1

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

custom menu in 4.1

All Replies

Posted by Community Admin on 08-Aug-2011 00:00

I am looking for some advice as far as custom menus go in SiteFinity.  This is our first project with SF so we are still in our infancy of knowledge with the product.  We have had our designer try to use the horizontal with dropdowns, along with the custom menu over-ridding css.  We briefly looked at the tree navigation, there are a lot of unneeded elements in the tree nav.  So I am wondering what would be the best way to get a custom navigation working with exact styling.  I feel like there should be a way to do a repeater within a repeater and just pull two data calls. I have implemented this menu http://www.fortwaynewebdevelopment.com/custom-navigation-menu-in-sitefinity-4/  the things I am missing on this menu are
1. second tier nav
2. knowing that when binding the tier 1 nav that a child page within is selected


Posted by Community Admin on 09-Aug-2011 00:00

Hello Adrienne,

The PageNode has a property Nodes that you can use to check of there are child nodes and add them to the datasource. Another option is using the binding to arraylist,generic list or an array using one of the RadControls( here is a sample with RadTreeView)
You can easily get the selected node using SiteMapBase.GetActuallCurrentNode and then perform the binding.

Regards,
Ivan Dimitrov
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Sep-2011 00:00

Um, the original link above no longer works. I've asked a similar question on this thread:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/developing-with-sitefinity/simple-ul-gt-li-gt-a-list-of-pages.aspx

Posted by Community Admin on 02-Sep-2011 00:00

Hi Dan,

Have you tried to search for the control  on the Marketplace?

www.sitefinity.com/.../search-results.aspx

result



Regards,
Ivan Dimitrov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 02-Sep-2011 00:00

Ivan,

Yes, I did find that control and I'm now using it. I updated my own question thread that I linked to above. It would be nice to find the source code for that type of control for additional customization, but as is, it works pretty well.

Posted by Community Admin on 02-Sep-2011 00:00

When I get back in the office next week I'll post my custom 2 tier menu Cheers

Posted by Community Admin on 06-Sep-2011 00:00

This was an example so please double check any code if used in production


<asp:SiteMapDataSource ID="TopNavStart" runat="server" ShowStartingNode="false" />
<asp:Repeater runat="server" ID="LeftNav" DataSourceID="TopNavStart" OnItemDataBound="FirstLevel_ItemDataBound">
    <HeaderTemplate>
        <ul id="nav">
    </HeaderTemplate>
    <ItemTemplate>
        <asp:Literal ID="litLIHolder" runat="server" /><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>' />
            <asp:Repeater ID="LeftSubNav" runat="server">
                <HeaderTemplate>
                    <ul class="sub_nav">
                </HeaderTemplate>
                <ItemTemplate>
                    <li>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>' />
                    </li>
                </ItemTemplate>
                <FooterTemplate>
                    </ul>
                </FooterTemplate>
            </asp:Repeater>
        </li>
    </ItemTemplate>
    <FooterTemplate>
        </ul>
    </FooterTemplate>
</asp:Repeater>





 protected void Page_Load(object sender, EventArgs e)
   
        PageSiteNode currentNode = SiteMapBase.GetCurrentNode();
        ViewState["MainNavCount"] = SiteMap.RootNode.ChildNodes.Count; 
        
   
 
    protected void FirstLevel_ItemDataBound(object sender, RepeaterItemEventArgs e)
   
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
         
            var data = e.Item.DataItem as PageSiteNode;
            int counter;
            if (ViewState["Counter"] == null)
           
                counter = 1;
           
            else
           
                counter = (int)ViewState["Counter"] + 1;
           


            
            if (data != null)
           
                if (data.ShowInNavigation == false)
               
                    e.Item.Visible = false;
               
           


            Literal lblLIHolder = (Literal)e.Item.FindControl("litLIHolder");
            
            if (counter == 1)
           
                HyperLink HyperLink1 = (HyperLink)e.Item.FindControl("HyperLink1");
                HyperLink1.CssClass = "first_nav_item";
           


            if (counter == Convert.ToInt32(ViewState["MainNavCount"]))
           
                HyperLink HyperLink1 = (HyperLink)e.Item.FindControl("HyperLink1");
                HyperLink1.CssClass = "last_nav_item";
           


            bool isSelected = false;
            SiteMapNode sNode = (SiteMapNode)(((RepeaterItemEventArgs)(e)).Item.DataItem);
            PageSiteNode currentNode = SiteMapBase.GetCurrentNode();
            try
           
                if (currentNode.Url.Equals(sNode.Url, StringComparison.OrdinalIgnoreCase))
               
                    isSelected = true;
               
           
            catch
           


           
            SiteMapNodeCollection childNodes = sNode.ChildNodes;
            foreach (SiteMapNode cNode in childNodes)
           
                try
               
                    if (currentNode.Url.Equals(cNode.Url, StringComparison.OrdinalIgnoreCase))
                   
                        isSelected = true;
                   
               
                catch
               


               
           




            ViewState["Counter"] = counter;


            if (isSelected)
           
                Repeater rptr = (Repeater)e.Item.FindControl("LeftSubNav");


                
                if ((!(childNodes == null) && (childNodes.Count > 0)))
               
                    rptr.DataSourceID = null;
                    rptr.DataSource = childNodes;
                    rptr.DataBind();
               
                
                lblLIHolder.Text = "<li id=\"" + sNode.Title + "\" class=\"on\">";
           
            else
           
                lblLIHolder.Text = "<li id=\"" + sNode.Title + "\" class=\"\">";
           


       
   

Posted by Community Admin on 08-Sep-2011 00:00

Dan,

Send over an email to cwoodard@apterainc.com - I'm sure we could provide the code for our CleanNav control to you for customization as it is a free control. As long as it isn't redistributed :)

This thread is closed