Reputation: 36463
Here is what I have:
Dim cmsManager As New Telerik.Cms.CmsManager()
Dim currentNode As Telerik.Cms.Web.CmsSiteMapNode = CType(SiteMap.CurrentNode, Telerik.Cms.Web.CmsSiteMapNode)
Dim currentPage As Telerik.Cms.ICmsPage = currentNode.GetCmsPage()
Dim currentPageId As Guid = currentPage.ID
Dim pageFromDb As Telerik.Cms.IPage = cmsManager.GetPage(currentPageId)
Me.LastUpdateDate = pageFromDb.DateModified
Unfortunately .DateModified
returns the last time that a page was edited instead of when it was last published. I've been looking through the documentation but I haven't been able to find any corresponding properties.
Upvotes: 2
Views: 441
Reputation: 301
For version 10, I'm using the following code:
var node = SiteMapBase.GetActualCurrentNode();
var itemVersions = VersionManager.GetManager().GetItemVersionHistory(node.PageId);
var lastPublishedItem = itemVersions.Where(i => i.IsLastPublishedVersion).FirstOrDefault();
var lastPublishedDate = lastPublishedItem.LastModified.ToString("dd MMMM yyyy");
I wish there's a more straight forward way to do this..
Upvotes: 1
Reputation: 36463
Here's the code I'm using now, it seems to be getting the correct date on Publish:
Dim cmsManager As New Telerik.Cms.CmsManager()
Dim currentPageId As New Guid(SiteMap.CurrentNode.Key)
Dim pageFromDb As Telerik.Cms.IPage = cmsManager.GetPage(currentPageId, False)
Dim staged As Telerik.Cms.IStagedPage = pageFromDb.GetVersion(pageFromDb.Version)
Me.LastUpdateDate = staged.DateModified
I'm not sure if there's a better way to do it though.
Upvotes: 1