Monday, August 25, 2008

Hide Document library name like "Pages" link from BreadCrumb

Always people like breadcrumb but always hate sharepoint breadcrumb just because of it shows document library name in breadcrumb when you are on the page which exists in that document library. Like:- There is one Test.apsx page in my Pages Document Library.
Sharepoint will show it like :- Site -> Pages ->Test.aspx . Everybody hate that thing because when use click on Pages link it will show user that document library and all items in it. Which no body want to show.
When i was caught doing this then i realize that how big this issue is specialy for client. Then i thought to resolve this issue.

So finally here is the script which can save your like (can hide Document Library like "Pages" link from breadcrumb):-




[script language="javascript" type="text/javascript"]
var breadCrumbs = document.getElementById('ctl00_PlaceHolderTitleBreadcrumb_ContentMap')
if (breadCrumbs != null)
{
if (breadCrumbs.childNodes.length >= 3)
{
if (breadCrumbs.childNodes[2].innerHTML.indexOf('Pages') > 0)
{
breadCrumbs.childNodes[1].innerHTML = "";
breadCrumbs.childNodes[2].innerHTML = "";
}
}
}[/script]
//Change '"[","]" to "<",">" in script tag.
Just put this code either in Master page or on the same page where you want to hide document library name from breadcrumb.

Enjoy breadcrumb rather hate it more.
Kuldeep Kadyan.

Update list item without changing the version even versioning is enable on the list

A few days back i need to update metadeta of my document library after uploading the file using custom upload form. I done quickly everything as you know i am not an expert so had left lot of things were pending in that. The main thing was that each time when my code update any item it was counting an update event not create event for server so its create new version each time. Two versions were there within a single second
1. one file upload time
2. one metadata updation time.

I was really fed up.....after a lot of searching i got the solution and writing here for you all guys.

SPList list = site.Lists["MyList"];
SPListItem listItem = list.Items[CurrentFileIndex];
listItem["FileCode"] = strFileCode;
listItem["Comments"] = txtComments.Text;
listItem.SystemUpdate(false);


here the main thing is that we are calling listItem.systemUpdate() method instead of listItem.Update() method.

Hope it will help out you guys.