This project is read-only.

Postlist.ascx Question

Topics: ASP.NET 2.0, Business Logic Layer, Controls
May 12, 2009 at 1:29 PM
Edited May 13, 2009 at 1:40 PM

Hey, I am attempting to modify the postlist.ascx control to hide the last post or any # of latest posts.


Does anyone know how I can write something into the loop to accomplish this?

Also to have it do this on the front page only.


Thanks for any help.

May 13, 2009 at 2:34 PM

By last post - do you mean latest post or latest X posts - if so - I have done something similar - I do not have the code with me now, but as I remember, I merely added the following after the line which gets the posts into the VisiblePosts collection

        List<IPublishable> visiblePosts = Posts.FindAll(delegate(IPublishable p) { return p.IsVisible; });

        if (HideFirstCount > 0)
            if (visiblePosts.Count < HideFirst
                visiblePosts.RemoveRange(0, visiblePosts.Count);
                visiblePosts.RemoveRange(0, HideFirst

This checks if the HideFirstCount property is more than 0, assuming it is, it then checks if the visiblePosts Collection contains more posts than the value of the HideFirstCount property, if it does not it removes all the posts from the collection, however, if the collection contains more posts than the HideFirstCount property, it removes the required number of posts - the remainder of the control is unaltered - as I recall from memory

I assume that like me you have a control which is specific for the latest/featured post and so want to display it differently and not have it duplicated inthe PostList below


May 13, 2009 at 2:36 PM

Ya you are exactly right, I have a singlepost control that will have the full latest post, and under it all the other posts smaller, and ofcourse you post the latest and it shows twice on the page.

I'll try your suggestion and see how it works.