- Create a list with these fields:
- Title - Single line text
- Body - multiple lines of text
- Icon - Picture
- Put a content Query Web Part on the page
- Link it to your list in Query section
- Presentation:
- Styles: Fixed Image Size
- Fields to display:
- Image: Icon
- Title: Title [Custom Columns]
- Description: Body
- Open the XSL
- Go to All site Content > Style Library> XSL Style Sheets
- Make a backup copy of ItemStyle.xsl
- Download a copy of ItemStyle.xsl and open it in your favorite text editor
- Edit the XSL
- Remove the HTML from the body
- Search for all instances of <div class="description">
- Replace it with this block:
- <div class="description"><xsl:value-of disable-output-escaping="yes" select="@Description"/></div>
- Change the Fixed Image size style
- Search for FixedItemSize
- Replace the code with the block of code at the end of the post
- Upload ItemStyle.xls back to the library, and publish it.
<xsl:template name="FixedImageSize" match="Row[@Style='FixedImageSize']" mode="itemstyle">
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<div class="item">
<xsl:if test="string-length($SafeImageUrl) != 0">
<div class="image-area-left">
<a href="{$SafeLinkUrl}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<img class="image-fixed-width" src="{$SafeImageUrl}" title="{@ImageUrlAltText}"/>
</a>
</div>
</xsl:if>
<div class="link-item" style="border-bottom: 1px solid #EDEDED;">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}" style="font-size:x-large;">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a>
<div class="description">
<xsl:value-of select="@Created" />
<xsl:value-of disable-output-escaping="yes" select="concat(substring(@Description, 1, 500),'...')"/>
</div>
</div>
</div>
</xsl:template>
Sources:
- https://blog.tallan.com/2014/10/01/displaying-enhanced-rich-text-in-content-query-web-part/
- https://blog.mastykarz.nl/generating-short-description-content-query-web-part/
- http://www.xsltfunctions.com/xsl/fn_substring.html
- http://www.xsltfunctions.com/xsl/fn_concat.html
- https://sharepointmalarkey.wordpress.com/2010/10/12/sharepoint-internal-field-names-sharepoint-2010/
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.