Showing posts with label XSL. Show all posts
Showing posts with label XSL. Show all posts

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>