Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Making the SiteUrls.config selected link "light up"

Here are the steps on "lighting up" a selected navigation link in Community Server after we create and determine the url to our site article.  That's how the question was asked and I like the term "lighting up" so I'm using it here.  We want to make the menubar link to a content page be the selected tab in other words.  For our example the site article url is getablog.aspx and we've created the link in SiteUrls.config that looks like this.

<link name="getablog" navigateUrl="/content/Getablog.aspx" text="Get a blog here!" />

 

1) We start with \themes\[theme]\content\content.aspx.  Notice the MasterPageFile item.  We're going to make a copy of that master.Master file, add a SelectedNavigation link to the copied file, and update the MasterPageFile designation in this content.aspx file.


 

2) Make a copy of master.Master, name it anything you want.  We're naming it getablog.Master for consistency.



3) In getablog.Master we add a SelectedNavigation entry in the Header region.  Notice the Selected="getablog."  That's the name of our siteUrls.config link which will be selected when that master page is used.



4) We return to content.aspx and update the MasterPageFile designation.



Our new Menubar link is now selected when viewing the content page. 

Comments (13) | Post RSS RSS comment feed

Posted on 6/19/2007 6:43:12 PM by Dave Burke
Categories: Community Server
Tags:

Related posts

Comments (13) -

6/19/2007 8:50:07 PM Permalink

Strike One!
Strike Two!
Its a HIT!  GOING!  GOING!  GONE!!!  ITS A HOME RUN!!!

Smile

Bill Bosacker |

6/20/2007 6:48:39 AM Permalink

Are you trying to tell me it takes me a long time getting to the point, Bruiser?  Smile

Thanks for the colorful comment!

daveburke |

6/20/2007 9:07:39 AM Permalink

but you just changed the menu item for all content articles, didnt you? so your privacy page or whatever will now light up "getablog". Wouldnt it be better to set the SelectedNavigation programmatically depending on the content name - privacy/terms light up home, getablog lights up getablog, etc?

James Shaw |

6/20/2007 9:31:52 AM Permalink

James, true, I thought of that, but the question was for a single site content page.  Only site articles use /content/content.aspx, right?

As for a programmatic approach, you're saying to write a custom CS.Controls.SelectedNavigation.cs that passes an additional ContentName property?  Yeah, good idea.



daveburke |

6/20/2007 7:54:29 PM Permalink

Hehe, glad you liked it.  I thought it worked well.  Smile

Bill Bosacker |

6/21/2007 11:07:15 AM Permalink

Well, here we are.  You've taught me to fish!

Problem is now, I can only catch the one fish. Or, to put it another way, this technique is like a match: It only works once.

Sorry, but my frustration only grows, and I can see that you're just trying to help.

So, I thought, "I'll be cool and add some a CSControl:ConditionalContent blog to a test master to see if it'll work.  So I did.

        
            
                
            

            
                
            

        


It didn't work.  So I thought I needed to add an actual URL element to SiteUrls.config, which I did via an override:

  
    
  


So far, so good.  Then, I tried changing the navigation area to include a reference to this new element (after adding "getablog" to resources.xml for the text to display):



Whoops, that broke the entire site with a critical error reading siteurls.config.

This just sucks out loud.

Dustin |

6/21/2007 11:12:56 AM Permalink

For grins, I added the selectednavigation control to the falsecontenttemplate in my conditionalcontent element, and it didn't light up then, either!  It only lights up when it's by itself.  I'm just flabbergasted.

Dustin |

6/21/2007 11:21:54 AM Permalink

Try an onload check on url as I wrote about in this post for CS 2.1.  I don't know if it works for CS2007.

http://dbvt.com/blog/archive/2006/06/01/4633.aspx

daveburke |

6/21/2007 11:26:26 AM Permalink

Looks like this works (I'll have to test with a new article)

        
            
                
                
                

            

        

Dustin |

6/21/2007 11:31:40 AM Permalink

Nope, I thought it worked, but it didn't.

Dustin |

6/21/2007 11:53:42 AM Permalink

Dustin, Sorry about the trouble you're having.  I know, it seems ridiculous to only support a single content page and I'm sure there's a way without modifying the source or creating a new SelectedNavigation control.  However, as a coder I'd go the custom SelectedNavigation route and add a ContentPage property, then select the tab based on that property.

I'd have to sit down with this to find an alternative approach but am in the middle of my CS workday coding at the moment.  If I think of something else for you, I'll get back with you.  Or I wouldn't be surprised if someone else has a good idea.

daveburke |

6/21/2007 12:23:18 PM Permalink

I solved it.

Step 1: Create the article, and make sure its "name" doesn't have any spaces
Step 2: Add the to the section of the SiteUrls.config file.  Make sure the "name" attribute of the element is the same as the "article name" in Step 1.
Step 3: Per your details above, add a new master for content pages and assign it to the common content.aspx page
Step 4: In the new master you created, add the following to the OnInit, just before the switch statement:

Context.Items["SelectedNavigation"] = Page.Request.QueryString["contentname"];

There.  That only took me four days.

Dustin |

6/21/2007 12:35:11 PM Permalink

You must feel incredibly gratified at the moment, Dustin...

Ahh, yes.  Because the "contentpart_articlename" url takes a contentname querystring.  (An aspect we covered in Part II of the series. Smile  

Congrats on figuring it out and thanks for playing our game.  Talk to you again soon.

daveburke |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke