Apr 20

Add a content editor web part to the document library page. On the content editor web part, add the following javascript. Be sure to modify the value for strAction to what you need. In this case, it is set to redirect to SomePage.aspx with the ListID and ItemID Parameters.

<script type="text/javascript">
function Custom_AddDocLibMenuItems(m, ctx) {
 var strDisplayText = "Edit Item Metadata";
 var strAction = "window.location.href='../../Pages/SomePage.aspx?ListID=" + ctx.listName.substr(1, 36) + "&ItemID=" + currentItemID + "';";
 var strImagePath = "/_layouts/images/edititem.gif";
 CAMOpt(m, strDisplayText, strAction, strImagePath);
 CAMSep(m);
 return false;
}</script>

Jan 14
To deploy a wsp in SP2010
Posted by Wei in SharePoint Web Parts on 01 14th, 2011| | No Comments »

Start SharePoint 2010 Management Shell (As Administrator) and run the following

Add-SPSolution –LiteralPath C:\WebPart\packagedwebpart.wsp

then you can do this:

Install-SPSolution –Identity packagedwebpart.wsp –WebApplication http://sp2010 -GACDeployment 

or this:

In Central Admin, click on System Settings > Manage farm solutions to see the web part. Click on it and select Deploy to deploy it.

Depending on how the wsp has been created, you may need to enable the web part in the site collection features.

Jul 6
Hide buttons from lists
Posted by Wei in SharePoint Web Parts on 07 6th, 2010| | No Comments »

Simple one... add a content editor web part and add the following code:

<style>
.ms-menubuttoninactivehover{
 display: none;
}
.ms-separator{
 display: none;
}
.ms-splitbuttondropdown{
 display: none;
}
.ms-viewselector{
 display: none;
}
.ms-listheaderlabel{
 display: none;
}
</style>

You'll notice that some of those buttons disappear.

Dec 2

stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 500000000
(hard limit of 500Mb)
 
Then to export the site and import it, run the following commands on your intranet
 
Note: you will need to give full control permissions to whoever is logged in on the intranet server for the site being imported to. What I did was to give full control to that account, then remove the user once the import is completed.
 
stsadm -o export -url http://intranet/path/to/website -includeusersecurity -nofilecompression -filename C:\somebackupfolder

Create the new site on your intranet.

stsadm -o import -url http://intranet/new/site -includeusersecurity -nofilecompression -filename C:\somebackupfolder

Oct 14

Here's a quick code snippet for updating user profile information in SharePoint

    SPSite siteCollection = null;
    SPWeb web = null;
    siteCollection = SPContext.Current.Site;
    web = siteCollection.RootWeb;

    web.AllowUnsafeUpdates = true;
    SPList list = web.Lists["User Information List"];
    SPUser user = web.SiteUsers["DOMAIN\user"];
    SPListItem item = list.Items.GetItemById(user.ID);
    item["FirstName"] = "John";
    item["LastName"] = "Smith";
    item["WorkPhone"] = "55378008";
    item["Office"] = "BigScholar.com";
    item.Update();

The List name needs to remain as "User Information List".

« Previous Entries