Stump the Panel » Site Managers and Site Collection Managers

Customising the view of announcements

(5 posts)
  • Started 3 weeks ago by amila
  • Latest reply from EndUserSharePoint
  1. Hi,

    I am trying to customize the view of announcements web part to do the following;

    If the length (height) of one announcement is greater than a certain value (number of raws / characters etc...) then only to display a part of the announcement and show a "more" link that will take you to the announcements list.

    I tried this by limiting the height of the web part, but still it displays the whole announcement by increasing the height of the web part.

    I have done this before and know that, this is not that difficult but still i couldn't find out a solution.

    tks
    amila

    Posted 3 weeks ago #
  2. Well, here's a solution, but this solution doesn't know the height of the web part, it just always displays a "More" link:

    Create a new hyperlink field in your Announcements list, called More.
    Create a workflow in SPD, that will run when a new announcement is created:
    1. Build dynamic string:
    Store
    /[%Announcements:Path%]/DispForm.aspx?ID=[%Announcements:ID%], Click here
    in variable AnnounceURL

    2. Set field in current item:
    Set More to Variable:AnnounceURL

    Now, in the announcements web part, add the More field.
    When new announcements are created, this URL will now be added. The reason for the comma and the "click here" part in the dynamic string, is so that the users don't have to see the big long string of the URL.

    You can turn on the management of content types in your announcements list, and hide this field from forms.

    Laura Rogers

    Posted 3 weeks ago #
  3. if i understood your question properly, then here is a jquery solution
    just change 10 on this line
    var maxChar = 10;
    to what ever maximum characters you want showen for each item

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function() {
    
    var maxChar = 10;
    var annItem = $(".ms-vb").find(">div[id^='{']").get();
    
    	$.each(annItem, function(i,e){
    	  x = $(e).text().length;
    	   if (x>maxChar)
    		  $(e).html($(e).text().substring(0,maxChar) + "...<a href=\"Lists/Announcements/AllItems.aspx\">More</a>");
    	});
    
    });
    </script>
    Posted 3 weeks ago #
  4. paltomonte
    Member

    Going in the opposite direction...
    How can I force the announcement view to show the entire announcement instead of truncating with the "more" link? I tried modifying the above jquery with maxChar = 1000 value but it did not work. Seems this only works to shrink the number of characters displayed. There is some upper limit that SP enforces regardless.

    Posted 3 days ago #
  5. Not sure if this will help in the discussion, but Lee recently posted a screencast that might show a different way to attack an announcments web part:

    http://www.endusersharepoint.com/?p=1310

    Posted 3 days ago #

RSS feed for this topic

Reply

You must log in to post.