Shorten field content in List Views in SharePoint Designer

Case:

I have a list called Introducing and the list has a column called Body. Body has a type of multiple lines of text.

One of the list views displays the Title and Body columns. There are entries that have a lot of content in the Body column. To make it look tidy and clear, we’d like to only display the first 200 characters of the content and use “…” to indicate more content.

Final result:

Solution:

  1. Open up the site in SharePoint Designer.
  2. From the left Site Objects panel, select Lists and Libraries. In the middle of the page, choose the list that you want to manipulate.
  3. To make sure that I don’t mass up with other views, I created a new view in the Views pane called Short.
  4. Click on Short view to open it up.
  5. Optional step. (On the Option tab in the Ribbon, click Add/Remove Columns to choose the columns that you want to display in this view. )
  6. On the top Ribbon, click on the Home tab->Advanced Mode. Note: you need to be the site collection administrator to have this option enabled.
  7. Go to the Design tab->Customize XSLT->Customize Entire View
  8. Change the display to Split and click on the Body content, not the Title field. The code of the content should be highlighted in the editor. The code looks like this <xsl:value-of select=”$thisNode/@*[name()=current()/@Name]” disable-output-escaping=”yes”/>
  9. Replace the above code with: <xsl:value-of select=”substring($thisNode/@*[name()=current()/@Name], 1, 200)” disable-output-escaping=”yes”/><xsl:if test=”string-length($thisNode/@*[name()=current()/@Name]) &gt; 200″>…</xsl:if>
  10. Save the changes.
  11. Ctrl+F to bring up the Find and Replace window. Navigate to the Replace tab.
  12. In the Find what box, type in ddwrt:ghost=”hide”, replace it with empty string. Yes, we want to get rid of this. It prevents you from editing them.
  13. Save and see the view in the browser.

Helpful links:

Modify XsltListView in SharePoint designer not saving

sharepoint designer 2010 – custom xslt in blog/default.aspx not saving

Unable to display this Web Part error

Unable to display this Web Part

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s