Home » Sharepoint 2010RSS

Truncating Blog Posts

Does anyone know how to truncate the blog posts that are shown on the a main page? 

I've been tasked with creating a blog for my director to publish his conference updates. Some of these updates can run into 5 - 6 pages. I'm looking for a way to truncate these down on the main page and add in a small "Read More" link. I've found jQuery scripts and html modifications for 2007 but they do not work in 2010.

Any ideas?

 

3 Answers Found

 

Answer 1

Hi,

The jquery  script works fine with 2010. Just changed the jquery path in the script.

Please refer the below changed version.

<script type="text/javascript">
if(typeof jQuery=='undefined'){
  var jQPath = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js'
  document.write('<script src="',jQPath,'" type="text/javascript"><\/script>');
}
</script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<style type="text/css">
.collapseText  {height:26px;overflow:hidden}
</style>
<script type="text/javascript">
function collapseText(){
  var html  = "<div class='ms-PostFooter'><a class='expand' href='#'>Read more...</a><div>";
  $("div.ms-PostBody","#WebPartWPQ2").addClass("collapseText")
   .after(html);
  $("a.expand","#WebPartWPQ2").click(function(event){
   $(event.target).parent().hide().prev().removeClass("collapseText");
   $("html,body").scrollTop(event.pageY);
   returnfalse;
  });
}
$(function() {
  collapseText();
});
</script>

 

 

Answer 2

I see, I'm quite new with Sharepoint and jQuery. I didn't realize you had to install jQuery to Sharepoint, I thought it was included. I'll try this again. 

 

Thanks.

 

Answer 3

You can also use a DataView Web Part to display blog  posts, then just use the substring function to limit the number of characters to display in a post.
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter