Saturday, August 6, 2011

Hide the “People and Group” section from breadcrumb in userdisp.aspx

If you want to hide any breadcrumb in sharepoint application pages, Then you are at the right spot. This can be done via javascript.

But Microsoft will not support/recommend modifying the OOTB application pages. 
So we can tweak the application page with a word of caution. It is entirely upto you to decide whether to follow it or not.

Here is the code for reference.

I'm hiding the "People and Group” in userdisp.aspx for those users from a different domain.

<input type="hidden" value="<%=Request.ServerVariables["Auth_User"]%>" id="user_name">

<script language="javascript">
var username=document.getElementById("user_name").value;
     alert(username);
   var domainname =username.substring(0,username.indexOf("\\"));
    alert(domainname.toLowerCase());

if(domainname.toLowerCase()=="Domain_name")//Please give Domain_name in lower case
{
var child=document.getElementById("ctl00_PlaceHolderTitleBreadcrumb_ContentMap").childNodes;

for(i=0;i<child.length;i++)
{
 if(child[i].hasChildNodes);
{
    var spantag=child[i].childNodes;
   
    for(j=0;j<spantag.length;j++)
    {
        if(spantag[j].tagName=="A")
        {
         var anchtag=spantag[j];
         hrefattrb=anchtag.getAttribute("href");
        
         if(hrefattrb.indexOf("people.aspx")!=-1)
         {
         anchtag.style.display="none";
         child[i].style.display="none";
         child[i+1].style.display="none";
         }
        
        }
    }
}
}
}
<script>

No comments:

Post a Comment