David Kitchen

Avatar

Just another SharePoint developer blogging

SharePoint Wiki Table of Contents using jQuery and ShUIE

So I’m back, playing around with ShUIE in the few spare moments of downtime at work, and today I have a gap-filler for you.

What’s missing from SharePoint Wikis? Well, don’t get me started but one obvious thing is a table of contents.

Scenario: You make a nice long page that acts as a living document and collaborative space, but then the scroll bar is squashed and people can’t easily jump to the part that interests them.

If only you had a table of contents that displayed the headers within the document and let you jump directly to that segment.

Well, here’s the answer for you:

screenshot-partial

Clickity click for the full size image.

If you head over to the ShUIE codeplex project you can grab the latest download which now includes the Wiki ToC.

WikiToC also features the first customisation that is using filters, the customisation only runs on:

  • Lists that have a BaseTemplate of 119 (Wiki Lists).
  • Pages that have a form mode of Display (which means the customisation does not run whilst the Wiki page is in New, Edit or Invalid modes).

The advantage of using ShUIE filters to limit where the script is included?

  • Reduced bandwidth as customisations only appear where needed.
  • Reduced debugging as customisations won’t appear where they’re not needed and cause unanticipated problems.
  • You could limit the use to a specific SPWeb, thereby making the customisation only available to part of the organisation.

Have fun.

22 Comments, Comment or Ping

  1. David Malikyar

    I installed the feature and executed the sql scripts successfully — both for the ShUIE Structure.sql as well as the WikiTOC.sql. I also activated the feature from the site collection features page. I proceed to create a new Wiki library but I don’t see one as depicted in the gif. Am I missing a step here? Any help is greatly appreciated.

  2. When installing ShUIE did you remember to edit the web.config file to include the database connection string?

  3. David Malikyar

    David,
    I did include the database connection string. The database is being accessed since I see activity via SQL Server Mngmt studio. I’m new to wikis. Do I need to tag text for it to appear in the toc? If so, how do I do that?

    Thanks.

  4. Erica

    For DavidK–
    Once the ‘code’ was installed, would the ‘user’ be able to see the wiki ToC jQuery after content (text etc..) was added or is there some other way to ‘invoke’ the jQuery ToC?
    Any Moss wiki ToC tips would be greatly appreciated.

  5. What are you seeing? Did you install and then nothing?

  6. Marco

    Hello David,

    I’m looking forward to trying out this ToC ;-0 it’s one of the biggest flaws in the SharePoint Wiki, and I’ve been searching for a (free) solution for some time now.

    One thing I was wondering about:
    Does this ToC work for multiple wiki page?

    Example:
    You have four wiki pages:
    - Home
    > Product 1
    ~ Productdescription 1
    >Product 2

    Can your solution create a ToC that shows this? Or does it only work for headings in one wiki page?

    Now we just need to add a discussionoption and an easy upload imagebutton to the wiki and where set to go :P

    I’ll let you now how the implementation works out ;-)

  7. Tomtom

    Hi

    I have 2 Sites, on the one i can see the TOC, on the other i can’t see it. Both sites have the same features enabled.
    In the past i had the TOC on the site where I now can’t see the TOC.

    Does anyone know what i have to do, to see the TOC again???

  8. Erica

    DavidK
    What were the ‘tags’ used again for ‘invoking’ the wikiToC? Were they H1 H2 etc??
    thanks for your help.
    e

  9. You just select one of the font sizes.

    The greater the font size, the less indentation in the ToC (it’s assumed that larger text is a more prominent heading in the ToC).

  10. David Malikyar

    DavidK,
    I never got a response from you regarding my post on 3/26/09. As I mentioned, everything appears to have installed correctly and I do see activity on the db via sql server manager. I created a wiki and changed the font of the text but I never see a TOC appear. Please advise.

    Thanks.
    Dave Malikyar

  11. Erica

    DavidK.
    We were able to get the MOSS Wiki ToC up an running, now we have to put it thru it’s paces both IA wise and a ‘robust’ real live case test. (A project that I’ve been working on for my organization.)

    One of the things I’d like to see is whether or not I can turn off the ToC per wiki page, or per wiki library. (Because some pages may not need a ToC… BUT… it’s better to have it than not wrt to MOSS wiki!)

    I don’t know of any other instance of MOSS Wiki ToC being used by a DoD organization, if you happen to know please pass along the POC info. We have some IA hurdles to overcome, but I”m hoping it won’t be too much of an issue.

    Thanks for your help and your efforts to improve Moss Wiki. :)

    Regards,– Erica

  12. John

    I got this working perfectly yesterday. I came in this morning and the ToC was gone. I checked my page source and it is giving me the error “missing } after property list”. The exception is thrown in the render function while minifying the js. This is strange since nothing has changed since yesterday. A re-install of ShUIE did not resolve. Any ideas?

  13. Bubba

    Ok, so I got the WikiTOC working. Three days later my TOC was missing. I checked everything, but found nothing wrong (except the error listed below). I decided to create another new wiki site as a test and it worked there. The one that was working just three days prior will just not work. The TOC on that site is gone. Have you ever seen this?

    To make things even more interesting that second site I created also lost its TOC after three days. I created a third wiki site and that one now works. The end result is two down and the one I created today is working for now.

    When I view the source of the page where the TOC is missing the error I see:
    Exception occured whilst rendering ShUIE scripts.
    ShUIE has been disabled to prevent breaking the page.

    Thanks in advance…

  14. Ah, I saw this somewhere else… it happened when the statistics engine ran each night and put datetimes in the propertybag. I have a solution checked into the source but just need to update the release package with it. I’ll do this a little later :)

  15. Erica

    I also have had a problem with the MOSS Wiki ToC disappearing after 1 day. The error that I also receive is:

    ..”Exception occured whilst rendering ShUIE scripts. ShUIE has been disabled to prevent breaking the page.”

    Let us know when the solution is available. :)

    Thank you.

  16. I have updated ShUIE v1 so that it includes the new package that deals with the DateTime error that resulted in the disappearing ToC.

    You only need to update the package, the database or property bags remain unaffacted.

    I have also released the ShUIE v2 package so that the recommended option is to now store the customisations in the SharePoint Site PropertyBag. This will result in fewer SQL calls (none!) as well as being faster (memory resident).

    Both packages resolve the bug mentioned in the last few comments. if you haven’t installed ShUIE go for v2, if you have, just reinstall v1 (there is now a setup.exe to make this easy for you).

  17. Erica

    Having problems with v2 install — the upload/install impacts the entire site collection such that the site collection needs to be reset.

    Any install tips/details you could share?

    Do you have the link to ShUIE v1? Only saw v2?

    Thanks for any help you can offer.

  18. James

    I grabbed the latest source off of CodePlex and installed with not problem. I installed the wiki entry and it indicated success like the following

    ShUIE.Admin -o enumentries -url http://testsite

    title : Wikis
    uid : 9cf3e073-9a44-4e42-931a-046368c5e369
    active: True

    I have created a Wiki Site Collection at http://testsite/sites/wiki and activated the site feature as described.

    I cannot see the ToC as described but I do see :

    in the page source. No references are in the page source for “wikiToc”

    Any idea why I am having this issue?

  19. Rowan

    Hey David,

    Like James I cannot see the TOC.
    Are we missing a step?

  20. Possibly… let me finish solving a work thing I’m doing and then reinstall the code locally… it may be that updates since I originally wrote it have broke the functionality (i.e. that the DOM has changed significantly enough for the JavaScript not to work).

  21. Tom H

    David -
    Thanks again for your work on this! I was having the same problem with the TOC displaying (version 2), until I modified the “contexts” in the Wiki Toc.xml file – it won’t work for me at all if I leave the pageMode invalid=true setting in there. If I leave just baseTemplate=119 (or no context at all, ala the HelloWorld example) the TOC displays fine.
    BUT…….when clicking an item in the TOC, it just takes us to the doclib that all of the WikiPages are stored in – not farther down the page or to the linked in doc.
    Seems like it’s probably a javascript thing to me, but I am not a javascript guy.
    Any ideas?

    Tom H.

  22. pams

    David
    What do I need to change in web.config to add a database string.I have installed and run the admin commands but could not see the TOC.Plese so help me I am looking for this, this is pretty urgent

Reply to “SharePoint Wiki Table of Contents using jQuery and ShUIE”