Skip to main content

www.iwkid.com

Go Search
Home
Blog
Playground
Code Snippets
TweakSP
Contact Me
  
www.iwkid.com > Code Snippets  

Code Snippets

Modify settings and columns
Helpful IW Code Snippets
  
View: 
Sort by AttachmentsUse SHIFT+ENTER to open the menu (new window).
CodeFilter
SharePoint OnLoadUse SHIFT+ENTER to open the menu (new window).
JavaScript
function FunctionName() {
    // Do something
}
 
_spBodyOnLoadFunctionNames.push("FunctionName");
Add the SharePoint AssemblyUse SHIFT+ENTER to open the menu (new window).
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
  in a Data ViewUse SHIFT+ENTER to open the menu (new window).
XSL
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
Show all Web Parts for a pageUse SHIFT+ENTER to open the menu (new window).
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "http://servername/site"
$pageUrl = "default.aspx"
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$web =$site.OpenWeb()
$scope = [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared
$mgr = $web.GetLimitedWebPartManager($pageUrl, $scope)
$mgr.WebParts | Format-Table Title, WebBrowsableObject
Run with elevated permissionsUse SHIFT+ENTER to open the menu (new window).
C#
SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // do something
});
Increase the size limitation while you save site as template and include contentUse SHIFT+ENTER to open the menu (new window).
STSADM
stsadm -o setproperty -pn max-template-document-size -pv 40000000
MOSS Search Results as XMLUse SHIFT+ENTER to open the menu (new window).
XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>
Andy Burns