1

Currently have a page layout were I would like to be able to display the last modified date of an article. However I can't see how this can be done as there's no snippet in the snippet gallery were you can add modified or created dates. There is an article date option but this needs to be populated by the user. I just want the last modified date to show in display mode so user can see the last time the article was updated. Seems to be a simple thing to achieve but I can't see how to do this.

5

I think this still holds true, http://blog.brianfarnhill.com/2008/10/showing-the-date-modified-date-on-a-page-layout

<PublishingWebControls:LastModifiedIndicator runat="server" />

or

<SharePoint:FieldValue FieldName="Modified" runat="server" id="modified" ControlMode="display" />
  • 2
    For SP13 I've used the Custom ASP.NET Markup option in the snippet gallery and pasted in <SharePoint:FieldValue FieldName="Modified" runat="server" id="modified" ControlMode="display" /> which results in <!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet--> <!--SPM:<SharePoint:FieldValue FieldName="Modified" runat="server" id="modified" ControlMode="display" />--> <!--CE: End Create Snippets From Custom ASP.NET Markup Snippet--> I've added this to my page layout and it has worked cheers for your help. – Neil McKay Sep 30 '13 at 23:38
  • thanks, I got it to work on my 2013 SP Site with the second solution. However, on some WebApp, the date won't be shown, resulting in a JS crash in the page (no more js working). I've noticed that happens mostly on the list WebApps. How can I secure the date value if null ? – Alex Nov 27 '14 at 13:35
  • if it's dectected as null by your JS code, then just construct a new date object and use that – Eric Alexander Nov 28 '14 at 13:16
3

We had a similar question, but we were restricted from modifying any sitewide files. The administrator would not permit changes to the master page.

Workaround: the REST API for Sharepoint 2013 lets you pull any metadata from any list or library. A few lines of JavaScript pulled in the Modified Date and the name/userid of the user.

var relativePageURL = _spPageContextInfo.serverRequestPath;
var siteURL = _spPageContextInfo.webAbsoluteUrl;         
var query = siteURL + "/_api/web/getfilebyserverrelativeurl('/"+ relativePageURL +"')?    $select=TimeLastModified,ModifiedBy/Title,ModifiedBy/LoginName&$expand=ModifiedBy";

Working sample is at this location: https://github.com/kpereyra/SharepointWikiFreshIndicator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.