SiteUrls_override.config: Support for inserting node into navigation

This post has 4 Replies | 4 Followers

Top 200 Contributor
Male
Posts 106
Points 1,495
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

Top 25 Contributor
Posts 1,539
Points 14,730
MVPs
X.Static replied on Thu, May 10 2007 4:36 PM

 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
Top 25 Contributor
Posts 948
Points 14,515
CS Developers

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
Top 200 Contributor
Male
Posts 106
Points 1,495

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

 

Sean Winstead

Four Roads

  • | Post Points: 5
Top 75 Contributor
Male
Posts 266
Points 1,140

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