Showing posts with label xslt. Show all posts
Showing posts with label xslt. Show all posts

Friday, June 1, 2012

XSLT template display part of article as summary

When created news, articles, and etc..., I want to take part of article as summary displayed in listing and headlines.I Created XSLT which can be used for this functionality:


<xsl:template name="trimPara">
    <!-- pass the string to be cropped with required string length -->
    <xsl:param name="stringLenRequired"/>
    <xsl:param name="stringInput"/>
    <xsl:value-of disable-output-escaping="yes" select="substring($stringInput,1,number($stringLenRequired))"/>
    <xsl:value-of disable-output-escaping="yes" select="substring-before(concat(substring($stringInput,number($stringLenRequired)+1,number($stringLenRequired) +20),' ' ),' ')"/>
    <!-- to make it a full word -->
    <xsl:if test="string-length($stringInput) > number($stringLenRequired)">...</xsl:if>
  </xsl:template>



You can call this template by the following:


   <xsl:call-template name="trimPara">
            <xsl:with-param  name="stringLenRequired">200</xsl:with-param>
            <xsl:with-param name="stringInput" select="@Body"/>
          </xsl:call-template>
        </div>


Monday, May 14, 2012

Add Lync Presence to SharePoint List column with XSL Stylesheet

If you want display Lync link with your contact list.
  1. Add column to the list Single line of text will call Presence.
  2. Edit Contact List Web Part Set XSL Link Property with new xsl.
  3. Create a XSL file with a style sheet, this style will add presence based on the Email field in the Contact list.
    <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" xmlns:o="urn:schemas-microsoft-com:office:office">
     <xsl:include href="/_layouts/xsl/main.xsl"/>
     <xsl:include href="/_layouts/xsl/internal.xsl"/>
     <xsl:template name="FieldRef_Text_body.Presence" match="FieldRef[@Name='Presence']" mode="Text_body">
      <xsl:param name="thisNode" select="."/>
      <xsl:variable name="etternavn">
       <xsl:value-of select="$thisNode/@Title" />
      </xsl:variable>
      <xsl:variable name="fornavn">
       <xsl:value-of select="$thisNode/@FirstName" />
      </xsl:variable>
      <xsl:variable name="fulltNavn">
       <xsl:value-of select="concat($fornavn,' ',$etternavn)" />
      </xsl:variable>
      <xsl:variable name="itemID">
       <xsl:value-of select="$thisNode/@ID" />
      </xsl:variable>
     
      <xsl:variable name="sipAfter">
       <xsl:value-of select="substring-after($thisNode/@Email,':')" />
      </xsl:variable>
      <xsl:variable name="sip">
       <xsl:value-of select="substring-before($sipAfter,'"')" />
      </xsl:variable>
     
       <div id="PresenceLink_{$itemID}"><span class="ms-imnSpan"><img border='0' height='12' src='/_layouts/images/imnhdr.gif' onload="IMNRC('{$sip}')" ShowOfflinePawn='1' style='padding-right: 3px;' id="PresencePawn_{$itemID}" alt='pawn' /> <a href='' id="ProfileLink_{$itemID}"><xsl:value-of select="$fulltNavn" /></a></span></div>
     </xsl:template>
    </xsl:stylesheet>