This post explains how you can display author and last modified in item display templates.
If you take any display template you get to see Manged Property mappings of 'EditorOWSUSER' and 'LastModifiedTime'.
These manged property holds value for user who modified the item(anything like blog, document etc) and last modified time.
Open SharePoint designer and Edit your item template html in Advanced mode.
First get the values of the both as follows
To get User:
var author = ctx.CurrentItem.EditorOWSUSER
This will get the user object data from context, which looks something like
| Ph2AdminQA | 693A30232E777C6D696E64747265655C70683261646D696E7161 i:0#.w|domain\ph2adminqa
If you want only User diplay name,$getItemValue() comes to rescue
var author =$getItemValue(ctx, "EditorOWSUSER")
This function returns the display name for the property.
To Get Date&Time:
var modifiedDate= ctx.CurrentItem.LastModifiedTime
This will get the date and time in UTC format like Sat Jul 19 2014 11:51:22 GMT+0530 (India Standard Time)
If you want only Date, use $getItemValue() as
var modifiedDate= $getItemValue(ctx, "LastModifiedTime")
This will give Time like Saturday, July 19, 2014
Now once you have both the values, you can display in any div or create your own html element and add it below the ctx.RenderBody(ctx) call.
<div> Modified by,_#= author =#_ On _#= modifiedDate=#_</div>
Refer http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000-spc14.aspx
for more useful tips when working with display templates
If you take any display template you get to see Manged Property mappings of 'EditorOWSUSER' and 'LastModifiedTime'.
These manged property holds value for user who modified the item(anything like blog, document etc) and last modified time.
Open SharePoint designer and Edit your item template html in Advanced mode.
First get the values of the both as follows
To get User:
var author = ctx.CurrentItem.EditorOWSUSER
This will get the user object data from context, which looks something like
| Ph2AdminQA | 693A30232E777C6D696E64747265655C70683261646D696E7161 i:0#.w|domain\ph2adminqa
If you want only User diplay name,$getItemValue() comes to rescue
var author =$getItemValue(ctx, "EditorOWSUSER")
This function returns the display name for the property.
To Get Date&Time:
var modifiedDate= ctx.CurrentItem.LastModifiedTime
This will get the date and time in UTC format like Sat Jul 19 2014 11:51:22 GMT+0530 (India Standard Time)
If you want only Date, use $getItemValue() as
var modifiedDate= $getItemValue(ctx, "LastModifiedTime")
This will give Time like Saturday, July 19, 2014
Now once you have both the values, you can display in any div or create your own html element and add it below the ctx.RenderBody(ctx) call.
<div> Modified by,_#= author =#_ On _#= modifiedDate=#_</div>
Refer http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000-spc14.aspx
for more useful tips when working with display templates
