Tuesday, December 16, 2008

Workarounds for bugs on SharePoint (V3) Blog

Hi Friends,
I have come across two problems on a WSS V3 blog site. They are,

  1. You have more than 10 posts on a blog that belong to one category, when you filter the posts for that category, the paging on the category.aspx doesnotwork when you use next and prev buttons, it shows you a message "There are no posts in this category.".

  2. You change the default view of a category that filters the blog posts on a Microsoft Windows SharePoint Services 3.0 blog site. When you visit the SharePoint Services 3.0 blog site, and then you click the link for the category that you changed, the blog posts are not filtered correctly. Instead, all the blog posts are displayed.
Workarounds:
Problem 1.
here goes the little workaround that i scripted for the paging related bug that one can encounter on category.aspx page.
Drag and add a content editor webpart to the category.aspx page on your blog,
open the script editor from the content editor webpart's tool pane,
simply copy the below script on to the script editor save it, Now you will find your paging working as expected.



<script language ="javascript" type = "text/javascript" >


function changeLink(){


JSRequest.EnsureSetup();


var Category = JSRequest.QueryString["Name"];


var parent;


var child;


for (var counter =0; counter < 100; counter++){


var elementId = 'bottomPagingCellWPQ'+ counter;


if (document.getElementById(elementId)){


parent = document.getElementById(elementId);


child = parent.childNodes[0].childNodes[0].childNodes[0];


if (child.childNodes.length > 0){


for (var y = 0; y < child.childNodes.length; y++ ){


if(child.childNodes[y].childNodes){


if(child.childNodes[y].childNodes[0].tagName){


theAnchorTag = child.childNodes[y].childNodes[0];


for( var x = 0; x < theAnchorTag.attributes.length; x++ ){


if( theAnchorTag.attributes[x].nodeName.toLowerCase() == 'onclick' ){


var str = theAnchorTag.attributes[x].nodeValue;


str = str.replace( '?', '?Name=' + Category + '\\u0026');


theAnchorTag.attributes[x].nodeValue = str;


onclk = theAnchorTag.attributes[x].nodeValue;


theAnchorTag.onclick = new Function(onclk);


}


}


}


}


}


}


break;


}


}


 


}


addLoadEvent(changeLink);


function addLoadEvent(func) {


var oldonload = window.onload;


if (typeof window.onload != 'function') {


window.onload = func;


}


else{


window.onload = function(){


if (oldonload) {oldonload();}


func();}


}


}


</script>





Problem 2:
Please find the workaround for this problem on Microsoft's support site @ http://support.microsoft.com/kb/939310