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 >
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.
Snag yourself a CS Tidbit!
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 >
That makes sense. My mind was stuck in the "one node at a time" mode.
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.
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com