SiteUrls_override.config: Support for inserting node into navigation

This post has 4 Replies | 4 Followers

Sean Winstead
Top 200 Contributor
Posts 102
Points 1,540
By: Sean Winstead
Posted: Thu, May 10 2007 2:17 PM

We have a customer who wants their navigation to be something like "Home", "Shop", "Blogs".

So I tried to figure out how to set up Siteurls_override.config such that I could cause "Shopping" to be inserted between "Home" and "Blogs". I came to the conclusion that I could not. The best I could do is cause "Shop" to show up either before "Home" or at the very end of all the navigation items using mode="add" and where="after" or where="start"

To get around this, I added support for mode="insert". I added the following code to method MergeXmlFiles in file \Components\Components\Merger.cs:

switch (mode)
{
  case "remove":
  ...
  ...
  case
"update":
  ...
  ...
  case "add":
  ...
  ...
  case "insert":
    where = overrideNode.Attributes["where"];
    at_start = (where == null || where.Value == "start");
    if (at_start)
      changedNode.CreateNavigator().InsertBefore(overrideNode.InnerXml);
    else
     
changedNode.CreateNavigator().InsertAfter(overrideNode.InnerXml);
  break;

  case "change":
  ...
  ...

 In siteurls_override.config I can then put the following:

 <Override xpath = "/SiteUrls/navigation/link[@name='home']" mode = "insert" where="after">
  <
link name="shop" resourceUrl="shop" resourceName="wiki"/>
</
Override >

Sean Winstead Four Roads
 
X.Static
Top 25 Contributor
Posts 1,523
Points 14,475
MVPs
By: X.Static
Posted: Thu, May 10 2007 4:36 PM In reply to

 Good stuff...I've run into this limitation as well and this solves the issue nicely. It's too bad that method is static, otherwise this could be moved out into an external library.

 
  • Post Points: 5 |
Wyatt Preul
Top 25 Contributor
Posts 918
Points 16,900
CS Developers
By: Wyatt Preul
Posted: Thu, May 10 2007 4:46 PM In reply to

You can also use the existing functionality and do the following:

 <Override xpath = "/SiteUrls/navigation/link[@name='home']" mode = "update">
    <link name="home" resourceUrl="home" resourceName="home" roles="Everyone" />
    <link name="shop" resourceUrl="shop" resourceName="wiki"/>
 </Override >

 

Wyatt Preul
Wyatt - The Geek Cowboy
 
  • Post Points: 35 |
Sean Winstead
Top 200 Contributor
Posts 102
Points 1,540
By: Sean Winstead
Posted: Thu, May 10 2007 5:07 PM In reply to

That makes sense. My mind was stuck in the "one node at a time" mode.

 

Sean Winstead Four Roads
 
  • Post Points: 5 |
interscape
Top 75 Contributor
Posts 255
Points 950
By: interscape
Posted: Fri, Feb 29 2008 1:43 PM In reply to

That method does not work, at least not in CS2008 Beta 1. It throws a NullReferenceException that doesn't get written to the system's Application Event Log. When you pull out the second link, the error goes away.

But this is cool thought... it would be a really great trick if it worked that way.

 

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

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