A solution for the problem of highlighting navigation menu links for custom pages

rated by 0 users
This post has 2 Replies | 3 Followers

diego.gnesi
Not Ranked
Posts 5
Points 70
By: diego.gnesi
Posted: Mon, Jul 23 2007 11:24 AM

I've not found a valid and definitive solution to this problem searching on this forum, so I post my own one. The solution works on CS 2007 and must be applied only one time: it will work also for newer pages.

1. Open the \Themes\CurrentThemeName\Content\content.aspx file in your editor.

2. Copy the following code after the </script> tag:

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderRegion" runat="server" >
<CSControl:SelectedNavigation ID="SelectedNavigation1" runat="Server" />
<head id="Head1" runat="server">
<CSControl:Head ID="Head2" runat="Server">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<CSControl:Style ID="Style1" runat="server" visible = "true" />
<CSControl:Style ID="Style2" runat="server" Href="../style/common.css" />
<CSControl:Style ID="Style3" runat="server" Href="../style/forum.css" />
<CSControl:Style ID="Style4" runat="server" Href="../style/gallery.css" />
<CSControl:Style ID="Style5" runat="server" Href="../style/common_print.css" media="print" />
<CSControl:Style ID="Style6" runat="server" Href="../style/forum_print.css" media="print" />
<CSControl:Style ID="Style7" runat="server" Href="../style/DynamicStyle.aspx" EnsureNotCachedOnPreview="true" />
</CSControl:Head>
</head>
</
asp:Content>

This code above is redundant, because it applies to the HeaderRegion ContentPlaceHolder it's default content, but it will allow us to reference the SelectedNavigation1 control.

 2. Replace the intial c# code for the Page_Load() event with the following lines:

void Page_Load()
{
    if (CurrentContent != null)
    {
        SetTitle(CurrentContent.Title,
true);
       
//Custom code
       
try {SelectedNavigation1.Selected = CurrentContent.Name;}
        finally {}
    }
}

3. Create you articles. The "article name" field is very important. Chose a name without spaces, like "links" or "contactus". Remind that you can specify a more friendly title in the headline field (i.e. "Some links for you guys" or "Contact Us").

4. Open the SiteUrls.config and add the following line to the "locations" section, under the "common node" (the "common" node is usually at the end of the locations section):

<locations type ="CommunityServer.Components.CSLocation, CommunityServer.Components">
    <location name="common" path="/" themeDir="common" >
        ...

        <!-- My code -->
        <
url name="X" path="content/X.aspx" />
    </location>

</locations>

Replace the "X" with the name of the article (both in the "name" and in the "path" attributes).

5. Under the navigation node, add the line corrisponding to the new menu link:

<link name="X" resourceUrl="X" text="Link" roles="Everyone" />

Replace the two "X" with the name of the article.

6. Repeat the steps 4 and 5 for every article you want to link on the menu bar

IMPORTANT: Due to caching, the menu could resoult changed or highlighted only after minutes. Be patient...

www.archeolab.net
 
Jose Lema
Top 25 Contributor
Posts 1,878
Points 37,765
CS Developers
By: Jose Lema
Posted: Fri, Aug 3 2007 9:11 AM In reply to

Thanks Diego for posting this!

One is glad to be of service...

Jose Lema

 
  • Post Points: 20 |
jasonkim
Not Ranked
Posts 17
Points 220
By: jasonkim
Posted: Wed, Mar 12 2008 3:43 PM In reply to

Hello,

This solution does not work in CS 2008.  After following the directions, the link takes me to the following path:

/error.htm?aspxerrorpath=/themes/default/content/content.aspx.  It should be resolving to an article.

Can someone please help?  I basically want the custom, article based, navigation item text to change color when it's active just like the default names, i.e. Home, Blogs, Media, etc.

Thanks in advance!

Jason

 

 
  • Post Points: 5 |
Page 1 of 1 (3 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com