Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# hobbis 5/16/2008 6:36 PM
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:
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;
			}
		}
# hobbis 5/19/2008 12:27 PM (edited 5/19/2008 12:40 PM)
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:
 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);
            }
        }