mo.notono.us

Tuesday, January 13, 2009

MOSS: Add Incoming Links to a Wiki Page with jQuery

Sharepoint’s wiki implementation is rudimentary, but still useful.  One of the corners cut in the implementation is that incoming links are on a separate page – you have to click the Incoming Links link (and wait for the screen to refresh) to see them.  It’d be much more user-friendly to show these links on the same page as the content.

Turns out with jQuery this is a fairly trivial exercise,  at least for a single Wiki page*:  Simply add a Content Editor Web part to the page and copy the following code into the Source Editor.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
  //get the url for the incoming links page
  u = $("a[id$=WikiIncomingLinks_LinkText]")[0].href;

  //create a target container and load it with the incoming links
  //filtered to show the links list only
  l = $("<div id='incomingLinks' style='border-top: solid 1px  silver'>").load(u + " .ms-formareaframe");

  //append the new container to the wiki content
  $(".ms-wikicontent").append(l);
});

</script>

It may be noted that the above code could even be combined into one single chain – I prefer the above for readability and debugging purposes.  Also not sure if I need to dispose of the local variables – this is a POC more than anything else.

Adding script through a CEW part

The incoming links are now on the page, right below the content:

Incoming Links directly on the Wiki Page

A more thorough implementation might position the links in a box in the upper left corner, and simultaneously removing the “Incoming Links” link.

*I haven’t quite thought out how to inject this throughout a wiki.  Any suggestions?

Labels: , , , , , ,

9 Comments:

  • I'm not sure of its viability, but you might give it a try to add this feature using a Control Adapter. The downside is that there is no granularity: the modification would be applied to all Wiki's in the particular Web Application.

    By Blogger Unknown, at Wednesday, January 14, 2009 1:25:00 AM  

  • I tried adding your script to a master page template. Now all new pages will show then incoming links by default.

    There are reasons you may not want to do this, but it might work for you depending on the situation.

    By Anonymous Anonymous, at Friday, February 27, 2009 4:21:00 PM  

  • Here's a starting point for adding the links to the top right menu:

    http://www.endusersharepoint.com/?p=1341

    I'm going to try adapting this for incoming links.

    By Anonymous Anonymous, at Wednesday, August 05, 2009 11:11:00 PM  

  • I've made Incoming Links a drop-down that appears on every wiki page on the site.

    See here:

    http://stackoverflow.com/questions/1242703/how-to-make-incoming-links-appear-as-a-drop-down-in-sharepoint-wiki

    By Blogger Unknown, at Thursday, August 06, 2009 10:27:00 PM  

  • Has anyone had any luck using this script in SharePoint 2010? I'd like to know how you did, since I can't get it to work. Thanks.

    By Blogger Ryan, at Tuesday, January 19, 2010 5:16:00 PM  

  • Considering how different SP 2010 pages are from MOSS (they're actually HTML compliant! Amazing!) this comes as no surprise.

    My suggestion is to use the browser Developer Tools (press F12 in IE) to identify the new div ids, etc.

    By Blogger Oskar Austegard, at Wednesday, January 20, 2010 5:22:00 PM  

  • Great post - didn't know much about the power of jQuery before. Thanks!

    By Anonymous Floschx, at Thursday, May 27, 2010 7:49:00 AM  

  • THank you so much for this post. It helped me immensly in 2007. I tried to update it for 2010, but had trouble. Was anyone ever able to upgrade the script? Thanks so much!

    By Blogger Janice Thorne, at Wednesday, June 09, 2010 12:36:00 PM  

  • 2010, show incoming links on the right

    http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010programming/thread/28ef9b01-57e9-448a-ba36-f1e68ad1e915

    By Anonymous Anonymous, at Thursday, August 25, 2011 1:30:00 AM  

Post a Comment

<< Home