An issue that always arises when creating a Content Page or adding custom Community Server features (like my
iTunes Library or
Blogroll, for example), is how do we get the Selected Menu Tab to get focus when we are on that page. We want this, in other words.
First, to create a new navigation tab we add it to the SiteUrls.config in the < Navigation /> area, like so:
< link name="myArticle" navigateUrl="/content/MySweetArticle.aspx" text="My Article" roles="Everyone" / >Now the trick is to send that link name back to the SelectedNavigation Class on the page that loads the new Content Page or feature. We do that by loading the SelectedNavigation control with the "Selected" property designating the name of the link in our SiteUrls.config file.
< CS:SelectedNavigation Selected = "myArticle" runat="Server" ID="Selectednavigation1"/ >
If we're adding a new Content Page, we can load the control in /Themes/default/Skings/Skin-ContentArticle.ascx.
But what if we have two Content Pages, or we add a new feature, like my goofy iTunes Library, for instance. Well, in the case of my iTunes Library, I made new LayoutTemplate.ascx and BlogMaster.ascx templates which is where I passed the "Selected" property to the SelectedNavigation class.
If you want to be a dirty boy or girl, you could always hack the SelectedNavigation class itself and doing a URL check (as I did with my blogroll page.) I'm not proud of it, but here it is.
protected override void OnLoad(EventArgs e)
{
if (Page.Request.Url.ToString().IndexOf("linklist.aspx") > 0) // DBVT Added
Context.Items["SelectedNavigation"] = "blogroll";
else
Context.Items["SelectedNavigation"] = this.Selected;
base.OnLoad (e);
}That should do it. Everything we need to make those tab buttons go up and down when they're supposed to.
[tags: Community Server, CSNavigation]