Covers several approaches for user interface customization in SP2013 - using JSLink to customize a list and/or view, creating custom Display Templates for the Content Search web part, and different approaches for customizing the search hover panel.
Additional information added for the European SharePoint Conference 2014
2. • Independent Consultant
• Head of Development, Content and Code
• Blog: www.sharepointnutsandbolts.com
• Twitter: @ChrisO_Brien
• LinkedIn: http://uk.linkedin.com/in/
chrisobrienmvp
About me
10. Advanced CSR possibilities
• Modify list data/schema in OnPreRender
– E.g. lookup something dynamically
• Use SPClientRenderer.Render() to obtain HTML:
– From arbitrary data
– Outside of page context
– In AJAX methods
16. Dynamic values in query
{User}
•Match profile field
e.g. User.Department
{Page}
•Match field value e.g.
Page.MyField
{Site}
•Match current site
e.g. Site.Url
{SiteCollection}
•Match current site
collection e.g.
SiteCollection.Url
{Today}
•Date filtering e.g.
Today-7
{Term}
•Match current
managed nav term
Several tokens available:
17. Provisioning Display Templates
• Two options in publishing sites:
Provision JS file only Provision HTML file only. “Touch” it to
generate JS file
+ No code required, just XML
(Module tag)
- Also need Feature receiver or remote
code to “touch” HTML file (for event
receiver to generate JS file)
- Updates can be difficult (edit
JS, or generate JS elsewhere)
+ Updates are easy (edit HTML)
= Recommended for Office 365 = Recommended for on-premises
19. SP2013 search recap
• Search scope on steroids
Result
Source
• Best Bet on steroidsQuery Rule
• E.g. Word doc, person,
social post etc.
Result Type
• Visual rendering of an itemDisplay
Template
22. Hover Panel actions
• Footer actions can also be
– Common
– Specific
• Gotcha! Some item types do not use Common
actions
– E.g. Discussion
- Item_CommonHoverPanel_Actions.js
- Item_[FileType]_HoverPanel.js
24. JS tips for display templates
• jQuery? Can’t use document.ready() – DOM is not populated
– Specify function in ctx.OnPostRender instead
– These functions are called ONCE (on first render [mouseover])
• N.B. Array of functions is accessible in all files e.g. header, body,
actions etc.
• DON’T delete _#= ctx.RenderBody(ctx) =#_
– This executes Item_CommonHoverPanel_Body.js (inheritance
model)
26. Summary
• JavaScript is key to many SP2013 UI elements
• Examples shown:
– Customizing entire list UI
– Conditional formatting of a field
– Rendering of Content Search web part
– Customizing search hover panel (inc. AJAX)
• Lots of other possibilities too!