2010-04-16 53 views
2

以下是我有:如何獲取頁面上次在Sitefinity中發佈的日期時間?

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 

不幸的是.DateModified返回一個頁面被修改,而不是當它是最後公佈的最後一次。我一直在尋找the documentation,但我一直未能找到任何相應的屬性。

回答

1

這是我現在使用的代碼,它似乎得到正確的日期發佈:

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 

我不知道是否有更好的方法來做到這一點,雖然。

1

對於版本10,我用下面的代碼:

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"); 

我希望有一個更直接的方式來做到這一點..

相關問題