+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Display last modified date

Display last modified date

9 posts, 0 answered
  1. Samir
    Samir avatar
    14 posts
    Registered:
    12 May 2008
    01 Apr 2009
    Link to this post
    Hello,

    I was wondering if there was a feature/module in sitefinity 3.6 running on .net 2.0 to display the last modified date of the website/page dynamically. Since there will be lot of people in our organization posting diffenret news item, creating different events, and web pages, and not all of them being familiar with editing the footer in the master page for the site, I was wondering if there was a module that could capture the date and time stamp when anything in the sitefinity website is published and then display that in masterpage template.

    Thanks in advance.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Apr 2009
    Link to this post
    Hello Developer,

    You can add some code to Global.asax that runs on Application_Start.
    IContent object has DataModified property as well.

    Here is a sample

     void Application_Start(object sender, EventArgs e)   
        {  
            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);  
            // Code that runs on application startup  
     
        }  
        void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)  
        {  
            if (e.CommandName == "CreateContent" || e.CommandName == "UpdateContent")  
            {  
     
                Telerik.Cms.Engine.IContent content = e.CommandArguments as Telerik.Cms.Engine.IContent;  
                if (content != null)  
                {  
                    content.GetMetaData("Title" + content.ProviderName.ToString() + content.DateModified);  
                  // write this data somewhere  
                }  
            }  
        } 


    I hope this helps.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Peter Graasbøl
    Peter Graasbøl avatar
    34 posts
    Registered:
    30 Jul 2009
    30 Jul 2009
    Link to this post

    I am with so far, but what should I insert in my UserControl, which can display "Last updated" in a MasterPage (as Samir describes). Would you please help me with this? It would be a great help. Thanks in advance!

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jul 2009
    Link to this post
    Hi Peter Graasbøl,

    Below is a sample code for a different approach that you can use to get all content items ( you can get to the first one or last one from the list if you want)

           ContentManager newsManager = new ContentManager("News"); 
            IList list = newsManager.GetContent(); 
            foreach (IContent content in list) 
            { 
                string modified = content.DateModified.ToString(); 
                Response.Write(modified); 
            } 

    You can display the date in a RadGrid control. In its Item template you can add Image

    <ItemTemplate> 
    <asp:Image ID="Image1" AlternateText="progress" BorderWidth="0px" runat="server"></asp:Image> 
    </ItemTemplate> 

    Then you can update the grid using Timer.

     <asp:Panel ID="Panel1" runat="server"
            <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick" /> 
        </asp:Panel> 

          public void Timer1_Tick(object sender, EventArgs e) 
            { 
                RadGrid1.Rebind(); 
            } 


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Peter Graasbøl
    Peter Graasbøl avatar
    34 posts
    Registered:
    30 Jul 2009
    30 Jul 2009
    Link to this post
    Hi Ivan Dimitrov
    Thank you for your reply. What I need is the current page "DataModified" (/homepage.htm). Our client wants this show to all sides.
    The site we are about to convert to Sitefinity standard is http://www.nfs.as/composite-35.htm and here you can see DataModified on all sides (On the right top, OPdateret: xx-xx-xxxx). I'm sorry that I did not have explained it better last time!
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jul 2009
    Link to this post
    Hi Peter Graasbøl,

    Then you can use the code below. You should add it to user or custom control and drop it in your master or ICmsPage

    var pageManager = new CmsManager(); 
            var currentNode = SiteMap.CurrentNode as CmsSiteMapNode; 
            if (currentNode != null
            { 
                var currentPage = currentNode.GetCmsPage() as ICmsPage; 
                string datamodified = currentPage.DateModified.ToString(); 
                var label = new Label {Text = datamodified}; 
                Controls.Add(label); 
                // add more logic here 
                
            } 


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Peter Graasbøl
    Peter Graasbøl avatar
    34 posts
    Registered:
    30 Jul 2009
    30 Jul 2009
    Link to this post
    Hi Ivan Dimitrov
    It got me back on track. Many many thanks!
  8. Hydo L
    Hydo L avatar
    98 posts
    Registered:
    31 Mar 2010
    24 Sep 2010
    Link to this post
    I want to show the last site update on all the pages. How can I do that?
    Please can anyone help?

    Regards,
    Hydo L
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Sep 2010
    Link to this post
    Hello Hydo L,

    I sent a reply to the other request you have opened.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
9 posts, 0 answered