Monday, July 7, 2008

Adding the New icon for content based on modified date.

Add to xsl:stylesheet tag:


xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"


Then add this template to be called later:


<xsl:template name="OuterTemplate.IsNew">
       <xsl:param name="ModifiedValue"/>
        <xsl:if test="((ddwrt:FormatDateTime(string(ddwrt:Today()), 1033, 'yyyyMMdd')) - (ddwrt:FormatDateTime(string($ModifiedValue), 1033, 'yyyyMMdd'))) &lt; 5" >
         <xsl:value-of select="string('&lt;img src=&quot;/_layouts/1033/images/new.gif&quot; alt=&quot;New&quot; /&gt;')"/>
  </xsl:if >
    </xsl:template>


Example of using the template:


<xsl:variable name="NewIcon">
         <xsl:call-template name="OuterTemplate.IsNew">
       <xsl:with-param name="ModifiedValue" select="@Modified"/>
    </xsl:call-template>
  </xsl:variable>


<xsl:value-of  disable-output-escaping="yes" select="$NewIcon"/>

Friday, July 4, 2008

Display Link to user via XSL Template: User Field Type similar to ddwrt:UserLookup

<xsl:template name="OuterTemplate.GetUserItem">
<xsl:param name="UserValue"/>
<xsl:param name="UserPart"/>
<xsl:choose>

<xsl:when test="string-length(normalize-space($UserValue)) = 0">
<xsl:value-of select="string('')"/>
</xsl:when>

<xsl:otherwise>
<xsl:choose>
<xsl:when test="$UserPart='Name'">
<xsl:value-of select="substring-after($UserValue,'#')"/>
</xsl:when>

<xsl:when test="$UserPart='UserID'">
<xsl:value-of select="substring-before($UserValue,';#')"/>
</xsl:when>

<xsl:when test="$UserPart='DisplayName'">
<xsl:value-of select="concat(substring-after(substring-after($UserValue,'#'),', '),' ',substring-before(substring-after($UserValue,'#'),', '))" />
</xsl:when>

<xsl:when test="$UserPart='UserURL'">
<xsl:value-of select="concat('/_layouts/userdisp.aspx?ID=',substring-before($UserValue,';#'))" />
</xsl:when>

<xsl:otherwise>
<xsl:value-of select="$UserValue" />
</xsl:otherwise>
</xsl:choose></xsl:otherwise>
</xsl:choose>
</xsl:template>

How to use: (@ReportOwner will be formated as [ID;#Last, First])

<xsl:template name="ByTheme" match="Row[@Style='ByTheme']" mode="itemstyle">

<xsl:variable name="Owner">
<xsl:call-template name="OuterTemplate.GetUserItem">
<xsl:with-param name="UserValue" select="@ReportOwner"/>
<xsl:with-param name="UserPart" select="'DisplayName'"/>
</xsl:call-template>

</xsl:variable>
       
<xsl:variable name="OwnerInfoURL">
<xsl:call-template name="OuterTemplate.GetUserItem">
<xsl:with-param name="UserValue" select="@ReportOwner"/>
<xsl:with-param name="UserPart" select="'UserURL'"/>      
</xsl:call-template>
</xsl:variable>

<a href="{$OwnerInfoURL}" target="_blank"><xsl:value-of select="$Owner"/></a>
</xsl:template>

Thursday, July 3, 2008

Complete list of Sharepoint Field types

AllDayEvent
Attachments
Boolean
Calculated
Choice
Computed
ContentTypeId
Counter
CrossProjectLink
Currency
DateTime
Error
File
GridChoice
Guid
Integer
Invalid
Lookup
MaxItems
ModStat
MultiChoice
Note
Number
PageSeparator
Recurrence
Text
ThreadIndex
Threading
URL
User
WorkflowEventType
WorkflowStatus
taken from: msdn.microsoft.com

Item Template added to interate all Nodes

Add to the bottom of:Style Library/XSL Style Sheets/ItemStyle.xsl

<xsl:template name="ShowRaw" match="Row[@Style='ShowRaw']" mode="itemstyle">
<xsl:for-each select="@*">
<p><strong>Name:</strong> <xsl:value-of select="name()" /> <strong>Value:</strong><xsl:value-of select="." /></p>
</xsl:for-each>
</xsl:template>


A better one:


<xsl:template name="ShowRaw" match="Row[@Style='ShowRaw']" mode="itemstyle">
<table style="border:1px silver solid;">
<xsl:for-each select="@*">
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="style">background-color:#dddddd</xsl:attribute>
</xsl:if>
<td style="border:1px silver solid;">
<xsl:value-of select="name()" />
</td>
<td style="border:1px silver solid;">
<xsl:value-of select="." />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>

OuterTemplate.GetGroupName Fix to include User Group

The corrected Template is below:

<xsl:template name="OuterTemplate.GetGroupName">
<xsl:param name="GroupName"/>
<xsl:param name="GroupType"/>
<xsl:choose>
<xsl:when test="string-length(normalize-space($GroupName)) = 0">
<xsl:value-of select="$BlankGroup"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$GroupType='URL'">
<xsl:variable name="Url">
<xsl:call-template name="OuterTemplate.FormatValueIntoUrl">
<xsl:with-param name="Value" select="$GroupName"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:with-param name="Url" select="$Url"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$GroupType='User'">
<xsl:value-of select="substring-after($GroupName,'#')"/>
</xsl:when>


<xsl:otherwise>
<xsl:value-of select="$GroupName" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Design: Rolling up Corporate Forms from all Intranet Department Sites

I'm working on creating a rollup content Query Web part (CQWP) to display all the corporate forms listed within our intranet. The basic architecture was to create a custom content type as follows:

[Corporate Form]
From preexsisting columns

  • Title:Single line of text
  • URL:Hyperlink or Picture
  • Comments:Multiple lines of text
  • Owner:Person or Group

New custom column

  • HelpURL:Publishing Hyperlink

Each site will have a list to store the [Corporate Form] content type. This list will allow administrators to add an entry for every corporate form either as an attatchment or a link to another list (such as for Infopath or standard lists).