Replacing text in columns with icons/images using XSL

Edit the webpart in SharePoint designer and place the below code in between <XSL></XSL> tags of the list.

<xsl:stylesheet xmlns:x=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:d=”http://schemas.microsoft.com/sharepoint/dsp&#8221; version=”1.0″ exclude-result-prefixes=”xsl msxsl ddwrt” xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime&#8221; xmlns:asp=”http://schemas.microsoft.com/ASPNET/20&#8243; xmlns:__designer=”http://schemas.microsoft.com/WebParts/v2/DataView/designer&#8221; xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; xmlns:msxsl=”urn:schemas-microsoft-com:xslt” xmlns:SharePoint=”Microsoft.SharePoint.WebControls” xmlns:ddwrt2=”urn:frontpage:internal” xmlns:o=”urn:schemas-microsoft-com:office:office”>
<xsl:include href=”/sites/contoso/_layouts/xsl/main.xsl”/>
<xsl:include href=”/sites/contoso/_layouts/xsl/internal.xsl”/>

<xsl:template name=”FieldRef_body.Status” match=”FieldRef[@Name=’Status’]” mode=”body”>
<xsl:param name=”thisNode” select=”.”/>
<xsl:choose>
<xsl:when test=”$thisNode/@*[name()=current()/@Name] = ‘Completed'”>
<img src=”/sites/contoso/Style Library/Images/1″ alt=”Status: {$thisNode/@Status}”/>
</xsl:when>
<xsl:when test=”$thisNode/@*[name()=current()/@Name] = ‘In Progress'”>
<img src=”/sites/contoso/Style Library/Images/2″ alt=”Status: {$thisNode/@Status}”/>
</xsl:when>
<xsl:otherwise>
<img src=”/sites/contoso/Style Library/Images/3″ alt=”Status: {$thisNode/@Status}”/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

 

Accordion style left navigation (quick launch) using pure CSS

<style type=”text/css”>
.s4-ql li.static
{
height: 2em;
overflow: hidden;
}

.s4-ql li.static:hover
{
height: auto;
}

.s4-ql li > span.menu-item
{
cursor: pointer;
}
/* Format the headers */
.s4-ql li > span.menu-item
{
cursor: pointer;
background: #0171C6;
color: white;
border: solid #fff;
border-width: 1px 0;
}
/* Format the accordion list items */
.s4-ql a.menu-item
{
color: #000;
background: #C9D4FF;
border: 1px solid #97C8F7;
border-bottom: none;
}
/* Format the header hover, list item hover and currently selected item */
.s4-ql li > span.menu-item:hover, /*Header */
.s4-ql a.selected, /* Selected */
.s4-ql a.menu-item:hover /* List item */
{
color: #FFF;
background: #073D7D;
}

.s4-ql ul.root > li.static
{
max-height: 2em;
overflow: hidden;
transition: max-height 1s linear;
}

.s4-ql ul.root > li.static:hover
{
max-height: 500px;
}

</style>

Create dynamic Fusion charts from SharePoint lists

Insert an empty DVWP then select the source list and add required columns, then edit the XSLT. Look for dvt_1.body tag and replace the contents in it with the below code.

Note: You need to upload the Fusion charts in any library first, before referencing the charts

<xsl:template name=”dvt_1.body”>

<xsl:param name=”Rows”/>

#This is what you need to insert

<xsl:variable name=”varColorString” select=”‘XXXXXXAFD8F8F6BD0F8BBA00FF8E46008E8ED646468E468E588526B3AA00008ED69D080DA186BE'” />
<xsl:variable name=”varChartValue”>
<xsl:for-each select=”$Rows[not(preceding-sibling::Row/@Status = @Status ) and @Status!=”]”>
<xsl:sort select=”@Status”/>
<xsl:variable name=”varTemp” select=”@Status”/>

&lt;set name=&apos;<xsl:value-of select=”(@Status)”/>&apos; value=&apos;<xsl:value-of select=” count($Rows[@Status = $varTemp])”/>&apos; /&gt;
</xsl:for-each>
<br/>
</xsl:variable>
<xsl:variable name=”varChartData”>
&lt;graph caption=&apos;Open risks &apos; xAxisName=&apos;Project Name&apos; yAxisName=&apos;Count&apos; showNames=&apos;1&apos; decimalPrecision=&apos;0&apos; formatNumberScale=&apos;0&apos; pieYScale=&apos;45&apos; pieRadius=&apos;70&apos; animation=&apos;1&apos; shadowXShift=&apos;4&apos; shadowYShift=&apos;4&apos; shadowAlpha=&apos;40&apos; pieFillAlpha=&apos;95&apos; &gt;
<xsl:value-of select=”$varChartValue” />
&lt;/graph&gt;
</xsl:variable>

<tr>
<td>
http://contoso/files/fcharts/FCF_Pie2D.swf?chartWidth=500&chartHeight=400

</td>
</tr>

#End here

</xsl:template>

Site Offline Custom Page

To create a site offline page, save the below code as html [app_offline.htm] and place it in ISS directory of web application. Just remove the file to resume the web application.

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Site Under Maintenance</title>
</head>
<body>

</body>
</html>

Note: The custom image must be uploaded at different location other than the target (web application)

Check in all the files which have no checked in version history

Save and run the below code as PowerShel script

$site = New-Object Microsoft.SharePoint.SPSite(“http://contoso/sites/teamsite”)

$root = $site.allwebs[0]

$folder = $root.GetFolder(“test2”)

#============================================================

# Function Set-CheckInFolderItems is a recursive function

# that will CheckIn all items in a list recursively

# You must take ownership of files using farm account prior to running this script

#============================================================

function Set-CheckInFolderItems([Microsoft.SharePoint.SPFolder]$folder)

{

# Create query object

$query = New-Object Microsoft.SharePoint.SPQuery

$query.Folder = $folder

# Get SPWeb object

$web = $folder.ParentWeb

# Get SPList

$list = $web.Lists[$folder.ParentListId]

# Get a collection of items in the specified $folder

$itemCollection = $list.GetItems($query)

# If the folder is the root of the list, display information

if ($folder.ParentListID -ne $folder.ParentFolder.ParentListID)

{

Write-Host(“Recursively checking in all files in ” + $folder.Name)

}

# Iterate through each item in the $folder

foreach ($item in $itemCollection)

{

# If the item is a folder

if ($item.Folder -ne $null)

{

# Write the Subfolder information

Write-Host(“Folder: ” + $item.Name + ” Parent Folder: ” + $folder.Name)

# Call the Get-Items function recursively for the found sub-solder

Set-CheckInFolderItems $item.Folder

}

# If the item is not a folder

if ($item.Folder -eq $null)

{

if ($item.File.CheckOutType -ne “None”)

{

if ($item.File.Versions.Count -eq 0)

{

# Check in the file

Write-Output “Check in File: “$item.Name” Version count ” $item.File.Versions.Count -foregroundcolor Green

$item.File.CheckIn(“Checked in By Administrator”)

}

}

}

}

$web.dispose()

$web = $null

}

Set-CheckInFolderItems $folder | Ft -autosize |Out-string -width 4096 >>C:\output.txt