Login

Username

Password





Register   Reset password

Get Cuyahoga at SourceForge.net. Fast, secure and Free Open Source software downloads

Forum

Welcome Guest Search | Active Topics | Members

Permanent subnavigation Options
hobbis
Posted: Friday, May 16, 2008 9:36:17 AM

Rank: Advanced Member
Groups: Member

Joined: 12/11/2007
Posts: 89
Points: 267
I have a 'Products' page which will have a load of sub pages to represent the products. So, there is a Products node then sub-nodes for each product. I would like to have the sub products permanently display in the left hand web page as a sub navigation. It will behave as though 'Products' is a root node. I'm looking at the 'NavigationLevelTwo' menu which behaves the way I want it to. But instead of using the root node to start from, I want it to start from 'Products' which is a sub node of root. Any idea how to do this?

Here is a reminder of the 'NavigationLevelTwo' class:

Code:

private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (this.Page is PageEngine)
                {
                    this._page = (PageEngine)this.Page;    
                    // Bind level 2 nodes
                    if (this._page.ActiveNode.Level > 0)
                    {
                        this.rptNav2.ItemDataBound += new RepeaterItemEventHandler(rptNav2_ItemDataBound);
                        this.rptNav2.DataSource = this._page.ActiveNode.NodePath[1].ChildNodes;
                        this.rptNav2.DataBind();
                    }
                }
            }
            catch (InvalidCastException ex)
            {
                throw new Exception("This control requires a Page of the type Cuyahoga.Web.UI.Page.", ex);
            }
        }



        private void rptNav2_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            Node node = (Node)e.Item.DataItem;
            if (node.ShowInNavigation && node.ViewAllowed(this._page.CuyahogaUser))
            {
                HyperLink hpl = (HyperLink)e.Item.FindControl("hplNav2");
                hpl.NavigateUrl = UrlHelper.GetUrlFromNode(node);
                hpl.Text = node.Title;
                UrlHelper.SetHyperLinkTarget(hpl, node);
                if (node.Level <= this._page.ActiveNode.Level && node.Id == this._page.ActiveNode.Trail[node.Level])
                {
                    hpl.CssClass = "subselected";
                }
            }
            else
            {
                e.Item.Visible = false;
            }
        }



Web Developer, Kent - Coolbytes
hobbis
Posted: Monday, May 19, 2008 3:27:55 AM

Rank: Advanced Member
Groups: Member

Joined: 12/11/2007
Posts: 89
Points: 267
Silly me, it was easy really, I used the HierarchicalMenu Control in the end and added a new function to it passing the id of the node that has to appear all times in the sub menu:

Code:

private void BuildNavigationTreeFromSpecificNode(int nodeID)
        {
            HtmlGenericControl mainList = new HtmlGenericControl("ul");

            Node specificNode = new Node();

            foreach (Node node in this._page.RootNode.ChildNodes)
            {
                if (node.Id == nodeID)
                {
                    specificNode = node;
                    break;
                }
            }

            //specificNode should be set
            if (specificNode != null)
            {
                if (specificNode.ShowInNavigation && specificNode.ViewAllowed(this._page.CuyahogaUser))
                {
                    //don't want specific node to appear, just it's children
                    //mainList.Controls.Add(BuildListItemFromNode(specificNode));
                }
                foreach (Node node in specificNode.ChildNodes)
                {
                    if (node.ShowInNavigation && node.ViewAllowed(this._page.CuyahogaUser))
                    {
                        HtmlControl listItem = BuildListItemFromNode(node);
                        if (node.Level <= this._page.ActiveNode.Level
                            && node.Id == this._page.ActiveNode.Trail[node.Level]
                            && node.ChildNodes.Count > 0)
                        {
                            listItem.Controls.Add(BuildListFromNodes(node.ChildNodes));
                        }
                        mainList.Controls.Add(listItem);
                    }
                }
                if (this._page.CuyahogaUser != null
                    && this._page.CuyahogaUser.HasPermission(AccessLevel.Administrator))
                {
                    HtmlGenericControl listItem = new HtmlGenericControl("li");
                    HyperLink hpl = new HyperLink();
                    hpl.NavigateUrl = this._page.ResolveUrl("~/Admin");
                    hpl.Text = "Admin";
                    listItem.Controls.Add(hpl);
                    mainList.Controls.Add(listItem);
                }
                this.plhNodes.Controls.Add(mainList);
            }
        }


Web Developer, Kent - Coolbytes
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Yet Another Forum.net version 1.9.0 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.