We have a request from our client to show the 5 most recently updated blogs on the site collections landing page. I have been able to, without issue, return the list of all of the posts from the "Posts" list of the blog site. I have even been able to go
so far as to return them in ascending/descending order based on the "PublishedDate" of the blog. The problem I am having is this ... the PublishedDate, Modified, and Created fields all return the same value. So if my Blog entry was created and added to a Category,
say this morning at 9:07 am, then all three fields would return 9:07 am. If I then added a comment to the blog at 1:23 pm, all three values would still be returning 9:07 am. This is not working for me since the date returned is not a true representation of
when the blog was last updated. I am hoping someone can see an issue with the code I have posted below.
NOTE: I am using VB.Net and have created a class, which implements List(of SPItem) and populated it with the items from the SPListItemCollection. I am doing this so I can use LINQ to query and filter the data.
Here is my code ...
Partial Public Class CommunitiesUserDrivenContentUserControl
Private Class GenericListBlog
Inherits List(Of SPItem)
Private _ListItemCollection As SPListItemCollection
Public Sub New(ByVal oListItemCollection As SPListItemCollection)
_ListItemCollection = oListItemCollection
Private Sub PopulateColection()
For Each oitem As SPListItem In _ListItemCollection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim thisweb As SPWeb
If WebPart.Tab3Site <> String.Empty Then
thisweb = SPContext.Current.Web.GetSubwebsForCurrentUser(0).Item(WebPart.Tab3Site.Replace("%20", " "))
thisweb = SPContext.Current.Web
Dim oGenericList As New GenericListBlog(thisweb.Lists("Posts").Items)
Dim tmp = (From c In oGenericList Order By CDate(c.Item("PublishedDate").ToString) Descending Take 5)
Dim resutls() As SPItem = tmp.ToArray
I hope someone can help me with this issue.