Thursday, March 20, 2014

How to customise SharePoint 2010 Blog Post

This article shows you how to customise SharePoint 2010 Blog Post's look on the Home page

From:

To (include Area information):

Note: Area is an additional column to the Post list.

Follow the following steps to customise the Blog Post look:

  • Copy the Blog Post layout template 'blog.xsd' from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\XSL from a SharePoint web front server and store it somewhere that is visible the Blog site.

In this example, I will create a folder called xsl under the Blog site root folder and store the xsd there. I will also rename it to BlogPost.xsl

Note:

To create the new folder, you can open the Blog Site in SharePoint Designer, click on All Files and then click on the New Folder button

To import the blogPost.xsl file, click the Import button and select the file

  • Open the BlogPost.xsd in SharePoint designer and look for the section with start with this comment

<!– BaseViewID='0′ and TemplateType='301′ is Home Page view for Blog's posts list –>

  • Find the <div> that define the layout for PostCategory and add the following text after that

<div>

<xsl:for-each select="$Fields">

<xsl:if test="@Name='Area' and not ($thisNode/@Area=")">

<!– output the Area field as "Area: " followed by the area –>

Area<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">:&amp;nbsp;</xsl:text>[<xsl:apply-templates select="$Fields[@Name='Area']" mode="PrintField"><xsl:with param name="thisNode" select="$thisNode"/></xsl:apply-templates>]

</xsl:if>

</xsl:for-each>

</div>

Note: @Name should be set to the correct field name syntax. To access the list's xml data, follow the instruction here http://vspug.com/dwise/2008/01/10/accessing-sharepoint-xml/

  • Save changes to the BlogPost.xsd file
  • Open the default.aspx in SharePoint Designer and make sure Area is included in the ListView Webpart column lists.
  • Select the Web part and click on the Add/Remove Columns button and then make sure Area is there.

  • Save changes to the default.aspx
  • Browse the default.aspx page and click on Site Actions\Edit Page

  • Edit the Post Web Part

  • Set the XSL Link to xsl/blogPost.xsl and click OK

  • Test the changes to make sure Area is included

 

No comments:

Post a Comment