SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Marc D Anderson 
Anatomy of a Display Template
Who Is Marc?
Session Overview 
• If you’ve enjoyed working with Data View Web Parts (DVWPs) and XSL in 
the past, SharePoint 2013’s Display Templates may be just the right thing 
for you. If you consider yourself a front-end coder, they may be just right 
for you as well. Display Templates are a new way to format and display 
data in SharePoint 2013 for search results, the Content Search Web Part 
(CSWP), Refinement Web Parts, and more. 
• Display Templates use HTML and JavaScript rather than XSL to format 
data on the client-side. We can develop our own Display Templates and 
combine them with third-party tools to create rich, powerful content 
rendering to equal the best websites out there. We’ll go through the 
anatomy of some of the most useful out-of-the-box Display Templates and 
look at how you can build your own useful customizations.
Standing on the Shoulders of Giants… 
• Corey Roth for great blog posts and a stellar SPC14 presentation 
(#SPC3000) 
• Benjamin Niaulin and Yohan Belval for allowing me to use several 
custom Display Template examples from the Sharegate blog
Display Templates 
•New in SharePoint 2013 
• JavaScript and HTML driven 
• Documentation is not great, but improving
Client Side Rendering (CSR) 
• Oft-used acronym with SharePoint 2013 
• Think of it as HTML, CSS, and JavaScript 
driven rendering of SharePoint data 
• Display Templates are an example of CSR 
• See also: JSLink
Display Templates Used By… 
• Search-dependent Web Parts 
• Content Search Web Part 
• Search Results Web Part 
• etc. 
• NOT Content Query Web Part 
• Note that SharePoint uses the same technology (Refiners, Filtering, 
etc.) 
One source of data + many display options = 
Content Management “Nirvana”
Content Search Web Parts (CSWPs) 
•New in SharePoint 2013 
• Display Template driven 
• Depends on indexing schedule 
• Continuous crawling helps, but 
not a panacea
Where Can You Use Display Templates? 
• Any page where you can add a search-driven Web Part 
• Not just for what we think of as “search”
Types of Display Templates 
• 
• 
• 
• 
• 
•
Working with Display Templates 
• Display Templates are stored in the 
Master Page Gallery: 
• ~sitecollection/_catalogs/masterpage/Display Templates 
• Can access via Design Manager, 
SharePoint Designer, or Mapped Drive 
• Find a Display Template that is most 
similar to what you want 
• Copy the existing HTML file and edit 
that copy
Working with Display Templates 
• When you create a display template by 
copying the HTML file for an existing 
display template in the Display 
Templates folder in the Master Page 
Gallery: 
• A .js file that has the same name is created in the location 
where you copied the HTML file. 
• All markup required by SharePoint Server 2013 is added 
to the .js file so that the display template displays 
correctly. 
• The HTML file and the .js file are associated, so that any 
later edits to the HTML file are synched to the .js file when 
the HTML file is saved. 
Source: SharePoint 2013 Design Manager display templates (MSDN) 
http://msdn.microsoft.com/en-us/library/office/jj945138(v=office.15).aspx
Working with Display Templates 
• Edit the HTML file in the editor of your choice 
(Dreamweaver, SublimeText, whatever) 
• Upload or simply save in place 
• A little tough to work with because the script is set 
in comments 
• Moves processing from the server to the client, so 
be prudent
Display Templates Often Work in Pairs 
• Two parts: Control and Item 
• Think of Control as the “wrapper” and Item as the 
code which is repeated per item in the result set 
• Use Control and Item templates in different 
combinations to meet your needs 
Image Source: SharePoint 2013 Design Manager display templates (MSDN) 
http://msdn.microsoft.com/en-us/library/office/jj945138(v=office.15).aspx
High Level Overview 
Control_blank. html 
• Full HTML document (HTML, HEAD, BODY) 
• Declarations: What data do you want to retrieve? 
• Script: Processes the data 
• Markup: How should we display the content?
Declarations in Display Templates 
• Title 
• mso:ManagedPropertyMapping 
maps from managed properties to 
“slots” 
• Mso:MasterPageDescription 
contains the description shown in 
selectors 
Item_Picture3Lines. html
JavaScript in Display Templates 
• JavaScript setup 
code 
• Script goes inside 
<!--#_ 
and 
_#--> 
blocks 
• ctx contains the 
current context 
Resource: Useful JavaScript to know when working with SharePoint Display Templates (#SPC3000) by Corey Roth 
http://dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000- 
spc14.aspx 
Control_List. html
Debugging Tips: Diagnostic Display Template 
• Shows the raw data coming back from the 
query 
• Great for making sure you have the data you 
intend 
• Helps ensure you have mapped the correct 
properties 
• Shows which mapped property “matched”
Debugging Tips: Debugging Tools 
• Just like any client side work, it’s very important to understand the 
DOM Inspector tools 
• Debugging client side is absolutely possible, but may not be what 
you are used to
Demos
Useful Links 
Microsoft 
SharePoint 2013 Design Manager display templates (MSDN) http://msdn.microsoft.com/en-us/ 
library/office/jj945138(v=office.15).aspx 
Display template reference in SharePoint Server 2013 http://technet.microsoft.com/en-us/library/jj944947.aspx 
Corey Roth 
Useful JavaScript to know when working with SharePoint Display Templates (#SPC3000) 
http://dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display- 
templates-spc3000-spc14.aspx 
4 tips for using jQuery with SharePoint Display Templates 
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/13/for-tips-for-using-jquery-with-sharepoint-display- 
templates.aspx 
Changing the look of Search using Display Templates and CSR 
http://channel9.msdn.com/Events/SharePoint-Conference/2014/SPC3000 
Sharegate Display Template Examples 
Animated Menu Display Template (Benjamin Niaulin) 
http://en.share-gate.com/blog/sharepoint-2013-animated-menu-search-display-template 
Image Slider Display Template (Yohan Belval) 
http://en.share-gate.com/blog/image-slider-with-sharepoint-2013-search-results
Contact Information 
Email marc.anderson@sympraxisconsulting.com 
Twitter @sympmarc 
Blog http://sympmarc.com 
SPServices http://spservices.codeplex.com 
SPXSLT http://spxslt.codeplex.com 
Books http://sympmarc.com/books 
The Middle Tier Manifesto http://bit.ly/middletier

Weitere ähnliche Inhalte

Mehr von Marc D Anderson

Mehr von Marc D Anderson (20)

SPC2019 - Managing Content Types in the Modern World
SPC2019 - Managing Content Types in the Modern WorldSPC2019 - Managing Content Types in the Modern World
SPC2019 - Managing Content Types in the Modern World
 
ECS2019 - Managing Content Types in the Modern World
ECS2019 - Managing Content Types in the Modern WorldECS2019 - Managing Content Types in the Modern World
ECS2019 - Managing Content Types in the Modern World
 
Rencontre Groupe d'usagers SharePoint Montreal - The Next Great Migration - C...
Rencontre Groupe d'usagers SharePoint Montreal - The Next Great Migration - C...Rencontre Groupe d'usagers SharePoint Montreal - The Next Great Migration - C...
Rencontre Groupe d'usagers SharePoint Montreal - The Next Great Migration - C...
 
RISPUG - Top Form - Using PowerApps to Replace List Forms
RISPUG - Top Form - Using PowerApps to Replace List FormsRISPUG - Top Form - Using PowerApps to Replace List Forms
RISPUG - Top Form - Using PowerApps to Replace List Forms
 
SPCNA 2018 - Top Form - Using PowerApps to Replace List Forms
SPCNA 2018 - Top Form - Using PowerApps to Replace List FormsSPCNA 2018 - Top Form - Using PowerApps to Replace List Forms
SPCNA 2018 - Top Form - Using PowerApps to Replace List Forms
 
SPCNA 2018 - The Next Great Migration - Classic to Modern
SPCNA 2018 - The Next Great Migration - Classic to ModernSPCNA 2018 - The Next Great Migration - Classic to Modern
SPCNA 2018 - The Next Great Migration - Classic to Modern
 
SPS New York City 2017 - The Lay of the Land of Client-Side Development circa...
SPS New York City 2017 - The Lay of the Land of Client-Side Development circa...SPS New York City 2017 - The Lay of the Land of Client-Side Development circa...
SPS New York City 2017 - The Lay of the Land of Client-Side Development circa...
 
ECS Zagreb 2017 - Content Types - Love Them or Lose It
ECS Zagreb 2017 - Content Types - Love Them or Lose ItECS Zagreb 2017 - Content Types - Love Them or Lose It
ECS Zagreb 2017 - Content Types - Love Them or Lose It
 
SPS Monaco 2017 - The Lay of the Land of Client-Side Development circa 2017
SPS Monaco 2017 - The Lay of the Land of Client-Side Development circa 2017SPS Monaco 2017 - The Lay of the Land of Client-Side Development circa 2017
SPS Monaco 2017 - The Lay of the Land of Client-Side Development circa 2017
 
Lions Tigers Teams - SPTechCon Austin 2017
Lions Tigers Teams - SPTechCon Austin 2017Lions Tigers Teams - SPTechCon Austin 2017
Lions Tigers Teams - SPTechCon Austin 2017
 
Oslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose ItOslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose It
 
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
 
SPTechCon Boston 2016 - Creating a Great User Experience in SharePoint
SPTechCon Boston 2016 - Creating a Great User Experience in SharePointSPTechCon Boston 2016 - Creating a Great User Experience in SharePoint
SPTechCon Boston 2016 - Creating a Great User Experience in SharePoint
 
SPTechCon Boston 2016 - Content Types - Love Them or Lose It
SPTechCon Boston 2016 - Content Types - Love Them or Lose ItSPTechCon Boston 2016 - Content Types - Love Them or Lose It
SPTechCon Boston 2016 - Content Types - Love Them or Lose It
 
SPC Adriatics 2016 - Creating a Great User Experience in SharePoint
SPC Adriatics 2016 - Creating a Great User Experience in SharePointSPC Adriatics 2016 - Creating a Great User Experience in SharePoint
SPC Adriatics 2016 - Creating a Great User Experience in SharePoint
 
SPC Adriatics 2016 - Alternative Approaches to Solution Development in Office...
SPC Adriatics 2016 - Alternative Approaches to Solution Development in Office...SPC Adriatics 2016 - Alternative Approaches to Solution Development in Office...
SPC Adriatics 2016 - Alternative Approaches to Solution Development in Office...
 
SharePointFest Konferenz 2016 - Creating a Great User Experience in SharePoint
SharePointFest Konferenz 2016 - Creating a Great User Experience in SharePointSharePointFest Konferenz 2016 - Creating a Great User Experience in SharePoint
SharePointFest Konferenz 2016 - Creating a Great User Experience in SharePoint
 
SharePointFest Konferenz 2016 - Alternative Approaches to Solution Developmen...
SharePointFest Konferenz 2016 - Alternative Approaches to Solution Developmen...SharePointFest Konferenz 2016 - Alternative Approaches to Solution Developmen...
SharePointFest Konferenz 2016 - Alternative Approaches to Solution Developmen...
 
SPTechCon Austin 2016 - Content Types-Love Them or Lose It
SPTechCon Austin 2016 - Content Types-Love Them or Lose ItSPTechCon Austin 2016 - Content Types-Love Them or Lose It
SPTechCon Austin 2016 - Content Types-Love Them or Lose It
 
SPTechCon Austin 2016 - Creating a Great User Experience in SharePoint
SPTechCon Austin 2016 - Creating a Great User Experience in SharePointSPTechCon Austin 2016 - Creating a Great User Experience in SharePoint
SPTechCon Austin 2016 - Creating a Great User Experience in SharePoint
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

SEF 2014 - Anatomy of a Display Template

  • 1. Marc D Anderson Anatomy of a Display Template
  • 3. Session Overview • If you’ve enjoyed working with Data View Web Parts (DVWPs) and XSL in the past, SharePoint 2013’s Display Templates may be just the right thing for you. If you consider yourself a front-end coder, they may be just right for you as well. Display Templates are a new way to format and display data in SharePoint 2013 for search results, the Content Search Web Part (CSWP), Refinement Web Parts, and more. • Display Templates use HTML and JavaScript rather than XSL to format data on the client-side. We can develop our own Display Templates and combine them with third-party tools to create rich, powerful content rendering to equal the best websites out there. We’ll go through the anatomy of some of the most useful out-of-the-box Display Templates and look at how you can build your own useful customizations.
  • 4. Standing on the Shoulders of Giants… • Corey Roth for great blog posts and a stellar SPC14 presentation (#SPC3000) • Benjamin Niaulin and Yohan Belval for allowing me to use several custom Display Template examples from the Sharegate blog
  • 5. Display Templates •New in SharePoint 2013 • JavaScript and HTML driven • Documentation is not great, but improving
  • 6. Client Side Rendering (CSR) • Oft-used acronym with SharePoint 2013 • Think of it as HTML, CSS, and JavaScript driven rendering of SharePoint data • Display Templates are an example of CSR • See also: JSLink
  • 7. Display Templates Used By… • Search-dependent Web Parts • Content Search Web Part • Search Results Web Part • etc. • NOT Content Query Web Part • Note that SharePoint uses the same technology (Refiners, Filtering, etc.) One source of data + many display options = Content Management “Nirvana”
  • 8. Content Search Web Parts (CSWPs) •New in SharePoint 2013 • Display Template driven • Depends on indexing schedule • Continuous crawling helps, but not a panacea
  • 9. Where Can You Use Display Templates? • Any page where you can add a search-driven Web Part • Not just for what we think of as “search”
  • 10. Types of Display Templates • • • • • •
  • 11. Working with Display Templates • Display Templates are stored in the Master Page Gallery: • ~sitecollection/_catalogs/masterpage/Display Templates • Can access via Design Manager, SharePoint Designer, or Mapped Drive • Find a Display Template that is most similar to what you want • Copy the existing HTML file and edit that copy
  • 12. Working with Display Templates • When you create a display template by copying the HTML file for an existing display template in the Display Templates folder in the Master Page Gallery: • A .js file that has the same name is created in the location where you copied the HTML file. • All markup required by SharePoint Server 2013 is added to the .js file so that the display template displays correctly. • The HTML file and the .js file are associated, so that any later edits to the HTML file are synched to the .js file when the HTML file is saved. Source: SharePoint 2013 Design Manager display templates (MSDN) http://msdn.microsoft.com/en-us/library/office/jj945138(v=office.15).aspx
  • 13. Working with Display Templates • Edit the HTML file in the editor of your choice (Dreamweaver, SublimeText, whatever) • Upload or simply save in place • A little tough to work with because the script is set in comments • Moves processing from the server to the client, so be prudent
  • 14. Display Templates Often Work in Pairs • Two parts: Control and Item • Think of Control as the “wrapper” and Item as the code which is repeated per item in the result set • Use Control and Item templates in different combinations to meet your needs Image Source: SharePoint 2013 Design Manager display templates (MSDN) http://msdn.microsoft.com/en-us/library/office/jj945138(v=office.15).aspx
  • 15. High Level Overview Control_blank. html • Full HTML document (HTML, HEAD, BODY) • Declarations: What data do you want to retrieve? • Script: Processes the data • Markup: How should we display the content?
  • 16. Declarations in Display Templates • Title • mso:ManagedPropertyMapping maps from managed properties to “slots” • Mso:MasterPageDescription contains the description shown in selectors Item_Picture3Lines. html
  • 17. JavaScript in Display Templates • JavaScript setup code • Script goes inside <!--#_ and _#--> blocks • ctx contains the current context Resource: Useful JavaScript to know when working with SharePoint Display Templates (#SPC3000) by Corey Roth http://dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000- spc14.aspx Control_List. html
  • 18. Debugging Tips: Diagnostic Display Template • Shows the raw data coming back from the query • Great for making sure you have the data you intend • Helps ensure you have mapped the correct properties • Shows which mapped property “matched”
  • 19. Debugging Tips: Debugging Tools • Just like any client side work, it’s very important to understand the DOM Inspector tools • Debugging client side is absolutely possible, but may not be what you are used to
  • 20. Demos
  • 21. Useful Links Microsoft SharePoint 2013 Design Manager display templates (MSDN) http://msdn.microsoft.com/en-us/ library/office/jj945138(v=office.15).aspx Display template reference in SharePoint Server 2013 http://technet.microsoft.com/en-us/library/jj944947.aspx Corey Roth Useful JavaScript to know when working with SharePoint Display Templates (#SPC3000) http://dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display- templates-spc3000-spc14.aspx 4 tips for using jQuery with SharePoint Display Templates http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/13/for-tips-for-using-jquery-with-sharepoint-display- templates.aspx Changing the look of Search using Display Templates and CSR http://channel9.msdn.com/Events/SharePoint-Conference/2014/SPC3000 Sharegate Display Template Examples Animated Menu Display Template (Benjamin Niaulin) http://en.share-gate.com/blog/sharepoint-2013-animated-menu-search-display-template Image Slider Display Template (Yohan Belval) http://en.share-gate.com/blog/image-slider-with-sharepoint-2013-search-results
  • 22. Contact Information Email marc.anderson@sympraxisconsulting.com Twitter @sympmarc Blog http://sympmarc.com SPServices http://spservices.codeplex.com SPXSLT http://spxslt.codeplex.com Books http://sympmarc.com/books The Middle Tier Manifesto http://bit.ly/middletier