B i t s O f S h a r e P o i n t C o n s u l t i n g L L C > B l o g P o i n t > Posts > SharePoint 2007 - Wiki View Solution
SharePoint 2007 - Wiki View Solution

I am not thrilled with the OOB wiki that SharePoint provides.  So I created a Wiki solution that can be put on any page within the site that provides a better view of the wiki with a nice navigation menu to the left.

Here is a screen shot of the solution.

wikiview.png

Here is a link to the Wiki Web Part that you can add to any page on the site that has the wiki.

Download the Web Part Here.

After you add this you will need to change several things:

  1. The link to ​jQuery is to Google, you may want to change that to a local copy.
  2. The link to SPServices needs to be changed to a location on your SP site.
  3. Next you will need to change the "wikiListName" to the name of your wiki.
    • Code: var wikiListName = 'Wiki';
    • Change what is in quotes to the name of your wiki.
  4. Last you will need to change the "startPageName" to the page you want to display first.  You will only need to put the name of the file, no need for extentions.
    • Code: var startPageName = 'Home';
    • Change what is in quotes to the name of the file you want to show first.

It should be work once this is all completed.

View a working example here.

Hope this helps.

Here is the 2010 version.

Below is the code:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://www.bitsofsharepoint2010.com/SiteAssets/jquery.SPServices-0.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 var wikiListName = 'Wiki View';
    var startPageName = 'Home';
 var thisSite =$().SPServices.SPGetCurrentSite();
 var wikiSite =  thisSite + '/' + wikiListName + '/' + startPageName + '.aspx';
 var root = location.protocol + '//' + location.host;
 var startSite = wikiSite.replace(root, '').replace(' ', '%20');
 
 $().SPServices({
operation: "GetListItems",
async: false,
listName: wikiListName,
completefunc: function (xData, Status) {
   $(xData.responseXML).find("[nodeName='z:row']").each(function() {
    //alert(xData.responseXML.xml);
    var fileName = $(this).attr("ows_LinkFilename").replace('.aspx', '');
    var URL = $(this).attr("ows_FileRef").split('#');
    var infoURL = URL[1].replace(/\s+/g, '%20');
    var listHtml = '<a href="#" info="/' + infoURL + '" class="wikiLinks">' + fileName + '</a><br/>';
    $("#wikiList").append(listHtml);
   });
  }
 });
 $('#wikiContent').load(startSite + ' .ms-wikicontent', function() {
  
  modifiedInfo(startSite);
  
  addWikiPage();
  wikiURL();
  
  wikiClick();
 });
 
 
 $('.wikiLinks').click(function(){
  
  var siteURL = $(this).attr('info');
  
  //alert(siteURL);
  
  $('#wikiContent').load(siteURL + ' .ms-wikicontent', function() {
   
   modifiedInfo(siteURL);
   
   addWikiPage();
   
   wikiURL();
   wikiClick();
  });
 });
 
 
 function wikiClick() {
  
  $('.ms-wikilink').click(function(){
   
   var mssiteURL = $(this).attr('info');
   
   //alert(mssiteURL);
   
   $('#wikiContent').load(mssiteURL + ' .ms-wikicontent', function() {
    
    modifiedInfo(mssiteURL);
    
    addWikiPage();
    
    wikiURL();
    
    wikiClick();
   });
  });
 }
 
 function wikiURL() { 
  $('.ms-wikilink').each(function(){
   var hrefSite = $(this).attr('href');
   $(this).attr('info', hrefSite);
   $(this).attr('href', '#');
  });
 }

 function modifiedInfo(pageURLM) {
  $('.infoWiki').remove();
  $().SPServices({
   operation: "GetListItems",
   async: false,
   listName: wikiListName,
   completefunc: function (xData, Status) {
    $(xData.responseXML).find("[nodeName='z:row']").each(function() {
     //alert(xData.responseXML.xml);
                                        var pageID = $(this).attr("ows_ID");
     var URLM = $(this).attr("ows_FileRef").split('#');
                                        var wikiEditPage =  thisSite + '/' + wikiListName + '/Forms/EditForm.aspx?ID=' + pageID;
     var infoURLM = "/" + URLM[1].replace(/\s+/g, '%20');
     var fileNameA = $(this).attr("ows_LinkFilename").replace('.aspx', '');
     var infoModified = $(this).attr("ows_Modified");
     var infoEditor = $(this).attr("ows_Editor").split('#');
     var listHtmlB = '<a class="edit-wiki-page infoWiki" href="' + wikiEditPage  + '">Edit this Content</a>';
     var listHtmlA = '<div class="infoWiki">Last Modified ' + infoModified + ' by ' + infoEditor[1] + '</div><br/>';
     
     if ( pageURLM == infoURLM) {
      
      $("#wikiModificated").append(listHtmlA);
      $("#wikiEditContent").append(listHtmlB);
     }
    });
    
   }
  });
 }
 
 function addWikiPage() {
  $().SPServices({
   operation: "GetList",
   listName: wikiListName,
   async: false,
   completefunc: function (xData, Status) {
    //alert(xData.responseXML.xml);
    id = $(xData.responseXML).find("List").attr("ID");
    var urlEdit = thisSite + '/_layouts/CreateWebPage.aspx?List=' + id + '&RootFolder=';
    //alert(urlEdit);
    //alert(id);
    $('#wikiPagAdd').append('<a href="' + urlEdit + '" class="edit-wiki-page infoWiki">Add a Page</a>')
    
    
    
   }
  });
 }
 
 

 
});
</script>
<script type="text/javascript">

function open(siteURL) {
 var options = {
  url: siteURL,
  title: "Add New Wiki Page",
  allowMaximize: true,
  showClose: true,
  dialogReturnValueCallback: silentCallback};
 SP.UI.ModalDialog.showModalDialog(options);}
function silentCallback(dialogResult, returnValue) {
}
function refreshCallback(dialogResult, returnValue) {
 SP.UI.Notify.addNotification('Operation Successful!');
 SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
</script>
<table style="width: 100%">
<tr><td valign="top" class="leftWiki"><br/><div id="wikiList" class="nav-wiki-page"></div></td>
<td valign="top"><br/><div id="wikiPagAdd"></div><div id="wikiEditContent"></div><div id="wikiContent"></div><div id="wikiModificated"></div></td>
</tr>
</table>
<style>
.leftWiki {
}
.infoWiki {
 font-weight: bold;
}
.edit-wiki-page {
 display: block;
 font-size: 11px;
 border:2px solid #eeeeee;
 background-color:#ffffff;
 color:#666666;
 float: right;
 text-align: center;
 padding:8px 12px;
 width:115px;
 font-weight: normal;
}
.nav-wiki-page {
 display: block;
 font-size: 11px;
 border:2px solid #eeeeee;
 background-color:#ffffff;
 color:#666666;
 text-align: left;
 padding:8px 12px;
 font-weight: bold;
 white-space:nowrap;
}
</style>

Comments

There are no comments yet for this post.
Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Addition: 2 + 1 = *


Please complete this equation.

Email


This is optional.
Attachments

 T o p i c P o i n t

 E x a m p l e P o i n t