SharePoint Blog – René Hézser

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 for “Navigation for Wikis

  1. 28th May 2009 at 16:52

    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

  2. 28th May 2009 at 21:48

    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é

  3. 26th June 2009 at 11:06

    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

  4. 26th June 2009 at 11:16

    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

  5. 26th June 2009 at 12:59

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

  6. 8th July 2009 at 12:32

    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

  7. 12th July 2009 at 11:50

    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é

  8. 20th July 2009 at 23:01

    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”

  9. 21st July 2009 at 22:02

    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é

  10. 24th September 2009 at 18:37

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

    WSS 3.0 Win2k3 SP2.

  11. 19th November 2009 at 08:28

    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(

  12. 15th December 2009 at 09:02

    Hallo René

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

  13. 23rd March 2010 at 08:42
  14. 30th March 2010 at 16:30

    I haven’t tested yet.

  15. 17th April 2010 at 05:09

    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

  16. 24th February 2013 at 10:25

    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

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.