Navigation for Wikis

Navigation for Wikis

image

The Wiki functionality SharePoint offers is great for quickly writing down stuff. It is often used for Server documentation.

Creating new pages is easy, and you can link pages. The ability to format the text is nothing fancy, but most of the time enough 🙂

Uploading images can be done with my custom field type, which stores images and documents in existing libraries. After the upload, a link is inserted into the Wiki body. –> Custom Field – Upload Files and Images

Now I want to introduce the navigation for SharePoint Wikis.

I realized the navigation through a control adapter. It extends the history button, which is shown on every Wiki page. The advantage is, that the navigation will have to be activated only per web application. Every Wiki page within that web application then has a navigation control beneath the Quick launch. You can see the navigation in action in my Wiki.

How does it work?

The start page in a Wiki library is used as root for the navigation. The text “Wiki Navigation” is linked to this start page.

Every link on this start page which points to another Wiki page is followed to create the navigation tree.

The navigation is cached for 20 minutes. But if a page changes within this time, the navigation will be rebuild and cached automatically.

The Wiki Navigation uses the same CSS as the Quick launch TreeView. This way it does not break the layout, if a node text is too long.

If you Wiki was created from the Wiki site template, it will use the same page for the navigation root you see when you browser to your page (usually the home.aspx).
But if you created a Wiki library on e.g. an empty Teamsite template, the Navigation uses the first Wiki page it will find inside the Wiki library. This is usually the "How to use this wiki library" page. You have to manually delete this page, so the homepage is the page with the lowest ID (see in the url if you edit a Wiki page).

URL Parameters

The Wiki Navigation can take three URL Parameters, to change the way it renders the navigation.

  1. Refresh=true
    This parameter will clear the cached data, reload it and store it in the cache again
  2. ExpandDepth=x
    Controls the depth TreeNodes are expanded. The path to the currently selected TreeNode is always expanded.
  3. MaxLength=x
    Shorten the TreeNode text to this length and add “…”

Requirements

WSS and .NET 3.5 (SP1)

WSPBuilder Extensions for the Visual Studio if you want to user the source code

Installation

Add the solution via stsadm. Deploy it to the web application where you want to use the navigation. Then activate the web application feature.

Download

SharePoint Solution RH.WikiNavigation.wsp

Source code RH.WikiNavigation-Source.zip

Update 7/20/2009

Fixed a bug with Wiki Libraries created without the Wiki page template

Update 8/10/2009

More Trace output during feature activation/deactivation.
The control adapter is now available on every UrlZone configured in Alternate Access Mappings.

16 Comments

Josef

Reply

Hello,
I have searched a long time for this web part. I have installed, but now nothing except Wiki Navigation is visible. So it doesn’t work. Do you have a explanation for that?

Greets and thanks
Josef

 

René Hézser

Reply

Hi Josef,
send me an email through the “Kontakt” link at the top of the page. Then I have you email address. We can then figure something out.

René

 

Martin

Reply

Hi Rene,

I’ve added and deployed the solution via stsadm.

I then activated the webapplication feature, but the wiki-naviagtion does not appear on my wiki-site.

Will I have to do something else for the navigation to appear ?

Regards,

Martin

 

Martin

Reply

Hi Rene,

I can now see the wiki navigation.
I had activated the webapplication feature for the wrong site
But now the navigation shows the following error message:

Error in OnPreRender: System.InvalidCastException: Das Objekt des Typs “System.DBNull” kann nicht in Typ “System.String” umgewandelt werden. bei RH.WikiNavigation.DataClasses.WikiData..ctor(WikiData parent, DataRow row, String listUrl) bei RH.WikiNavigation.WikiNavigationAdapter.AddLinkedWikiPages(WikiData item) bei RH.WikiNavigation.WikiNavigationAdapter.GetListItems(SPWeb web, SPList list, String wikiDataCacheName, String cacheTime) bei RH.WikiNavigation.WikiNavigationAdapter.c__DisplayClassb.b__9() bei Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state) bei Microsoft.SharePoint.SPSecurity.c__DisplayClass4.b__2() bei Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) bei Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) bei Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) bei RH.WikiNavigation.WikiNavigationAdapter.CacheData(SPWeb web, SPList list) bei RH.WikiNavigation.WikiNavigationAdapter.OnPreRender(EventArgs e)

What might be the problem ?

Regards,

Martin

 

Martin

Reply

I now installed it on a different server with the same effect.

 

Wolfgang

Reply

Hallo,

ich wollte heute das Modul in Betrieb nehmen. Nach Installation, Aktivierung und Verteilung (global) erhalte ich auf unserer Wiki-Seite folgende Fehlermeldung:
Error in OnPreRender: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei RH.WikiNavigation.WikiNavigationAdapter.AddLinkedWikiPages(WikiData item) bei RH.WikiNavigation.WikiNavigationAdapter.GetListItems(SPWeb web, SPList list, String wikiDataCacheName, String cacheTime) bei RH.WikiNavigation.WikiNavigationAdapter.c__DisplayClassb.b__9() bei Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state) bei Microsoft.SharePoint.SPSecurity.c__DisplayClass4.b__2() bei Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) bei Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) bei Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) bei RH.WikiNavigation.WikiNavigationAdapter.CacheData(SPWeb web, SPList list) bei RH.WikiNavigation.WikiNavigationAdapter.OnPreRender(EventArgs e)

Was mache ich falsch?
Besten Dank für eine Info,

MfG
Wolfgang Meyscheider
CTG

 

René Hézser

Reply

Hallo Wolfgang,
an diesem Problem arbeite ich gerade mit einem anderen Leser meines Blogs. Wenn wir eine Lösung gefunden haben, werde ich es hier schreiben.

Gruß
René

 

Danny G

Reply

I can only install as a global solution. When i try to deploy into a specific url I get “This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application”

 

René Hézser

Reply

Hi Danny,
that’s right. The solution is global.
Please activate the webapplication feature.
http://www.hezser.de/blog/archive/2008/08/31/installation-deployment-activation-of-features.aspx

René

 

Yuri Verbowski

Reply

Installed, activated and cannot figure out how to make this show on the sharepoint wiki – please help.

WSS 3.0 Win2k3 SP2.

 

Hans-Werner

Reply

Hallo René

gibt es schon Neuigkeiten bzgl. dieses Webparts?
Ich habe es über stsadm installiert und über die Zentraladministration global freigegeben. Leider ist in meinen Wiki-Bibliotheken nichts ersichtlich :O(

 

Hans-Werner

Reply

Hallo René

wie kann ich die Breite Deines WebParts anpassen?
Meine linke NavBar ist 200 Breit, die Wiki-Navigation jedoch wesentlich schmaler :O(

 

René Hézser

Reply

I haven’t tested yet.

 

George

Reply

Hello Rene. The solution is working as you described. But I do need some guidance on how to apply the URL parameters. I’m do not know where to edit the code to modify these parameters.

Thanks, George

 

Anil

Reply

Hi Rene,

your post is excellent.I want to use this feature in sp2010.

Can you provide the source code for sp2010.

please help me.i want to use this navigation in my sp 2010 site.

Thanks,
Anil

 

Leave a Reply