More in this section

Forums / Developing with Sitefinity / Last modified date - anyone?

Last modified date - anyone?

3 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    30 Sep 2007
    Link to this post
    Hi,

    Just a quick one cause I can't find the property for the life of me in the developer documentation (I know the sucker has got to be there!):

    Has anyone come across the method that will output the last publish or modified date (preferably last published date) of a page so that I can put it into my page or a usercontrol?

    I need to have this at the bottom of the page:

    Date Last Updated: Tuesday, 1 May 2007
    Authorising Manager: Owen Hanson  |  Author: Chris Stuart  |  Gatekeeper: Owen Hanson

    I will keep looking but any tips would be appreciated.

    Oh one more thing... more of a question for  Telerik probably but is it possible to add more default metadata fields to the "create page" form (you know along with page title, description and keywords)?

    The Authorising manager, author and gatekeeper fields need to be on each page and I was wondering if there is a way to have those fields appear at page creation time. I know you can add them manually but I don't want users having to create the extra fields each time manually then fill in the details.

    Also is the a way I can output the metadata values to the page as well as the head tag of the page?

    Cheers!


  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    01 Oct 2007
    Link to this post
    Hello Seth,

    You could get the current page and after that  you could use its DateModified property to display the last updated date. For example:

    ASCX code
    <b>Date Last Updated:</b> 
    <asp:Label ID="Label1" runat="server"></asp:Label> 

    C# code
     private void Page_Load(object sender, System.EventArgs e) 
            { 
                if (!IsPostBack) 
                { 
                    ICmsUrlContext context = CmsUrlContext.Current; 
                    CmsManager manager = new CmsManager(); 
                    IPage page = manager.GetPage(context.PageID); 
                    Label1.Text = String.Format("{0:dddd, dd MMMM yyyy}", (page as ICmsPage).DateModified); 
                } 
            } 

    You could access all the members of cms page through the ICmsPage object including Title, Name, HeaderControls and so on.

    As to your question: Sitefinity doesn't provide built-in functionality for extending cms pages i. e. for adding more properties. But you could save the necessary information for the page as keywords, separated by comma. Another approach is to provide your own implementation for inserting and saving the required data. You should link the data to the corresponding page by PageID.

    Hope this helps.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    01 Oct 2007
    Link to this post
    Thanks. I can work with that...

    Cheers,

    Seth
Register for webinar
3 posts, 0 answered