[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Truncate the body of an Announcement in SharePoint 2007

Posted on 2011-09-21
11
Medium Priority
?
1,086 Views
Last Modified: 2012-05-12
All,
I would like to truncate the body of text in the standard Announcement List that comes out of the box.

So far I have yet to figure out a solution.  Any feedback is very much appreciated!
0
Comment
Question by:erobles1963
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 11

Assisted Solution

by:svetaye
svetaye earned 2000 total points
ID: 36572632
Hello,
You can accomplish this using some JavaScript or using DataView Web part (the preffered option).
Please reade more about the DataView option here:
http://www.dlocc.com/articles/sharepoint-data-view-web-part-announcements-list/

In case you are using a DataView you can use the "substring" XSLT function on your item body.
It will look like this:
<xsl:value-of select="substring({@Body},50)" />"

It will truncate the "Body" field content to 50 characters.
0
 

Author Comment

by:erobles1963
ID: 36572832
Svetaye,

I've tried your recommendation but I'm not able to achieve the end results I'm looking for -- here is the actual code I am using:

<xsl:value-of disable-output-escaping="yes" select="substring((@Body),50)" /></div></TD>

v/r
Ernest
0
 
LVL 11

Expert Comment

by:svetaye
ID: 36572856
Does any part of the "Body" field content appears on the page?
Please try this code:
<xsl:value-of disable-output-escaping="yes" select="substring({@Body},0,50)" /></div></TD>


0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:erobles1963
ID: 36573234
svetaye,

I added the code as you asked and when I refreshed the page the "body" of all announcements were not shown.

I'm confused...

v/r/
Ernest
0
 
LVL 11

Expert Comment

by:svetaye
ID: 36573363
Ok,
Maybe your "body" column has another internal name?
Let's try to do it using the wizard.
On the right side of the screen you shoud see the "Data Source" toolbar (if you didn't close it). There you can see all list columns of the list. Did you see the "Body" column there?

If so please drag this column to your data view on the page. It will place the code that you need to display the body. Something like this: <xsl:value-of select="@FieldName" disable-output-escaping="yes"/>
There you will see the internal name of the "Body" column.

Delete the "@FieldName" include quotes and type double quote again - the auto complete will show up.
Click on the Expression builder and use the wizard to complete the code.

A few SharePoint XSLT tips here:
http://fuchangmiao.blogspot.com/2008/05/sharepoint-xslt-tips.html
0
 

Author Comment

by:erobles1963
ID: 36573611
Strange,

Here is what I get:

SharePoint Designer cannot render the XSLT in this Data View...

Failed seting processor stylesheet: 0x80004005: Expression expected.substring(-->{<--@Body},0,50)

Here is the code:

<TD Class="{$IDAFOBQG)"><div dir="{ddwrt:GetVar('Direction'))"><xsl:value-of disable-output-escaping="yes" select="substring({@Body}),0,50)" /></div></TD>
0
 
LVL 11

Expert Comment

by:svetaye
ID: 36573774
Please try to remove {} brackets from the {@Body} .
0
 

Author Comment

by:erobles1963
ID: 36574322
Svetaye:

When I remove the brackets and view there is no body content...it removes the content of the body.

This is so strange, as I did not think truncating could be so difficult in SharePoint.

Phil
0
 
LVL 11

Expert Comment

by:svetaye
ID: 36574479
I can see only one reason for this empty "Body" issue : you are using "Enhanced Rich Text" mode of the column. In this case you can't actually know how many characters you'l have in this field because Enhanced rich text field always add ome HTML to the content.

So try to set substring limit to some big number like 600 and check the content. if you see the result you have two options: use some big number as a limitation like 250 chars instead of 50 but it never will be exact the same number of characters (you don't know how many HTML characters every field contains) or you can change the column settings in the list settings and set it to "Plain Text". Plain text will contains only the text content without pictures'tables or any styles inside. Plane text you can truncate to 50 characters witout any issues.
0
 

Accepted Solution

by:
erobles1963 earned 0 total points
ID: 36598077
svetaye,

I will revisit this issue today.  I hope your guidance and potential solution resolves this matter.

v/r
Phil
0
 

Author Closing Comment

by:erobles1963
ID: 37307685
Excellent!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question