More in this section

Forums / Developing with Sitefinity / custom menu in 4.1

custom menu in 4.1

8 posts, 0 answered
  1. Brandwidth.com
    Brandwidth.com avatar
    8 posts
    Registered:
    17 May 2011
    08 Aug 2011
    Link to this post
    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


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Aug 2011
    Link to this post
    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
  3. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    01 Sep 2011
    Link to this post
    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
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Sep 2011
    Link to this post
    Hi Dan,

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

    http://www.sitefinity.com/marketplace/search-results.aspx?q=cleannav-control&start=0

    result
    • http://www.sitefinity.com/marketplace/modules/cleannav-control.aspx
    • http://www.sitefinity.com/marketplace/publishers/profile/aptera-inc.aspx


    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 >>

  5. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    02 Sep 2011
    Link to this post
    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.
  6. Brandwidth.com
    Brandwidth.com avatar
    8 posts
    Registered:
    17 May 2011
    02 Sep 2011
    Link to this post
    When I get back in the office next week I'll post my custom 2 tier menu Cheers
  7. Brandwidth.com
    Brandwidth.com avatar
    8 posts
    Registered:
    17 May 2011
    06 Sep 2011
    Link to this post
    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=\"\">";
                }


            }
        }
  8. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    08 Sep 2011
    Link to this post
    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 :)
8 posts, 0 answered