So you already know how to create custom XSL driven item View form for your list items, check out this article if not. In this article I will demonstrate how you can style fields that are rendered in the display form to match your custom look and feel. We`ll take Blog XSL template as an example located here (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\XSL\blog.xsl)
Search for the following string to find a blog item XSL template:
<xsl:template mode=”Item” match=”Row[../../@TemplateType='301' and (../../@BaseViewID='0' or ../../@BaseViewID='7' or ../../@BaseViewID='8' or ../../@BaseViewID='9')]“>
In here XSL matches ListTemplate equal 301 and ensures proper view is passed – in this case we`ll be working with BaseViewID = 7 defined in schema.xml of the list.
You will notice that some fields in this XSL are rendered as a plain text, like this `PublishedDate` one:
<xsl:value-of select=”$thisNode/@PublishedDate.MonthDayOnly” disable-output-escaping=”yes” />
Other fields have their rendering template defined, like the blog post category field:
<xsl:apply-templates select=”$Fields[@Name='CategoryWithLink']” mode=”Computed_body“>
<xsl:with-param name=”thisNode” select=”$thisNode”/>
</xsl:apply-templates>
You`ll notice custom rendering options defined for this field by using mode identifier: Computed_body
This and other identifiers will specify rendering rules that can be found right from the intellisense in your visual studio. Based on the template your field will be rendered with all the appropriate links to dependent items if applicable.
One of the easiest ways to find out how your template will look like is to open your site in SharePoint Designer 2010 and Open the Display Form of the list you`re customizing. Once you have a form opened, insert a data View into the form for you list and select a field to modify it`s available mode properties as shown below:
When done, transfer your values to XSL you have been modifying and see the result for yourself.
Good luck!