Friday, January 31, 2014

Office 365 SharePoint 2013 - Blog Customization - List By Year

I got an opportunity to customize the Office 365 SharePoint 2013 Blog customization.

Here is how you can show the years list for blog like "Archive" and "Category"

This post is demonstrated on video: http://youtu.be/CN9Knr5SUxQ
The XSL file you need.
Here is the XSL code:

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
 <xsl:output method="html" indent="no"/>
 <xsl:decimal-format NaN=""/>
 <xsl:param name="dvt_apos">'</xsl:param>
 <xsl:param name="ManualRefresh"></xsl:param>
 <xsl:variable name="dvt_1_automode">0</xsl:variable>
 <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
        <xsl:call-template name="dvt_1"/>
 </xsl:template>
 
 <xsl:template name="dvt_1">
  <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
  <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
  <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
  <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
  <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
  
  <xsl:choose>
   <xsl:when test="$dvt_IsEmpty">
    <xsl:call-template name="dvt_1.empty"/>
   </xsl:when>
   <xsl:otherwise>
    <ul class="ms-core-listMenu-item static ms-noList link-style1">
     <xsl:call-template name="dvt_1.body">
      <xsl:with-param name="Rows" select="$Rows"/>
     </xsl:call-template>
    </ul>
   </xsl:otherwise>
  </xsl:choose></xsl:template>
 <xsl:template name="dvt_1.body">
  <xsl:param name="Rows"/>
  <xsl:for-each select="$Rows">
   <xsl:call-template name="dvt_1.rowview" />
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="dvt_1.rowview">
        <xsl:variable name="PostDateFormatted" select="ddwrt:FormatDate(@PublishedDate,1033,1)"/>
        <xsl:variable name="PostYear" select="substring(substring-after(substring-after($PostDateFormatted,'/'),'/'),1,4)"/>   
    <xsl:variable name="NewGroup" select="ddwrt:NameChanged(string($PostYear), 0)" />
    <xsl:if test="string-length($NewGroup)">
  <li class="static linkitem">
   <a class="ms-core-listMenu-item">
    <xsl:attribute name="href">
    <xsl:value-of select="concat('/Blog/Date/',$PostYear)"/>
    </xsl:attribute>
    <xsl:value-of select="$PostYear"  />
   </a>
  </li>
  </xsl:if>
 
 </xsl:template>
 <xsl:template name="dvt_1.empty">

 </xsl:template></xsl:stylesheet>


Step 1

Go to your blog site and edit the page


Step 2

Insert "Post" webpart

Step 3

Speicify XSL file in webpart settings


Step 4

Specify a proper title to webpart

Step 5

Update "Title URL" & "Description" so that clicking on webpart title don't take anywhere and a description that user will when mouse over to webpart title

Done!




No comments: