Take your display template skills to the next level

56
Sorry, something went wrong

Transcript of Take your display template skills to the next level

Page 1: Take your display template skills to the next level

Sorry, something went wrong

Page 2: Take your display template skills to the next level

Elio Struyf

Page 3: Take your display template skills to the next level

”I’m a consultant with a passion

for branding and development”

Contact

@eliostruyf

www.eliostruyf.com

[email protected]

Elio StruyfSenior SharePoint Consultant

Page 4: Take your display template skills to the next level

Thank You to Our Sponsors!

Page 5: Take your display template skills to the next level

• Getting syntax highlighting

• Sorting results

• Refreshing results

• Loading more results

• Grouping results

Page 6: Take your display template skills to the next level

Intellisense

Syntax Highlighting

Page 7: Take your display template skills to the next level

HTML

Comment - JS

Page 8: Take your display template skills to the next level
Page 9: Take your display template skills to the next level
Page 10: Take your display template skills to the next level
Page 11: Take your display template skills to the next level

what comes next?object.tostring()object.tostring()object.getId() or object.GetId()

Page 12: Take your display template skills to the next level
Page 13: Take your display template skills to the next level
Page 14: Take your display template skills to the next level
Page 15: Take your display template skills to the next level

Options & Methods

• Copy & paste

• Removing the comments and adding them back before saving

• Create JS display templates

• Create a separate JavaScript file

• SynWrite supports multiple lexers in one file

• Is there another option?

Page 16: Take your display template skills to the next level

Srch.U.registerRenderTemplateByName

Srch.U.getRenderTemplateCollectionSrch.U.getRenderTemplateByName

Page 17: Take your display template skills to the next level

Creating a retrieval function

1. Create a function in the script block

2. Write your code in this function

3. Register your function with: registerRenderTemplateByName

4. Call your function with: getRenderTemplateCollection

Page 18: Take your display template skills to the next level
Page 19: Take your display template skills to the next level
Page 20: Take your display template skills to the next level
Page 21: Take your display template skills to the next level
Page 22: Take your display template skills to the next level
Page 23: Take your display template skills to the next level
Page 24: Take your display template skills to the next level
Page 25: Take your display template skills to the next level
Page 26: Take your display template skills to the next level
Page 27: Take your display template skills to the next level
Page 28: Take your display template skills to the next level

Adding sort actions to your

display templates

Page 29: Take your display template skills to the next level
Page 30: Take your display template skills to the next level
Page 31: Take your display template skills to the next level

#One -

Page 32: Take your display template skills to the next level

REST API - Sortable_api/search/query?querytext='*'&sortlist=‘Created:ascending'

Page 33: Take your display template skills to the next level

REST API – Not sortable_api/search/query?querytext='*'&sortlist=‘Title:ascending'

Page 34: Take your display template skills to the next level
Page 35: Take your display template skills to the next level

#Two -

Page 36: Take your display template skills to the next level

Adding your sorting options

d: 0 ascendingd: 1 descending

Page 37: Take your display template skills to the next level

How to implement something like this

Page 38: Take your display template skills to the next level
Page 39: Take your display template skills to the next level
Page 40: Take your display template skills to the next level

Refreshing your results

Could be useful when building dashboard pages

Interval

Manually

Page 41: Take your display template skills to the next level
Page 42: Take your display template skills to the next level
Page 43: Take your display template skills to the next level

By default you have paging

Page 44: Take your display template skills to the next level

What if you could do this

Page 45: Take your display template skills to the next level
Page 46: Take your display template skills to the next level

Maximum of 50 items

Page 47: Take your display template skills to the next level

Another way to achieve it

Result container

1. Result 12. Result 23. Result 34. Result 4

Search Result Web Part

Hidden container

1. Result 12. Result 2

Move results

Load moreLoad moreLoad more

1. Result 32. Result 4

http://elst.es/1xiOUVL

Page 48: Take your display template skills to the next level

Where is the grouping option?

Page 49: Take your display template skills to the next level

Content Query Web Part

Page 50: Take your display template skills to the next level
Page 51: Take your display template skills to the next level

What needs to be done?

#One - Control display templateCreate a new object to store each retrieved item

#Two - Item display templateRetrieve the managed property values

Place each item in the grouping object

#Three - Control display templateDisplay the results from that object

Page 52: Take your display template skills to the next level
Page 53: Take your display template skills to the next level
Page 54: Take your display template skills to the next level

https://github.com/SPCSR/

http://www.eliostruyf.com

Page 55: Take your display template skills to the next level
Page 56: Take your display template skills to the next level

”I’m a consultant with a passion

for branding and development”

Contact

@eliostruyf

www.eliostruyf.com

[email protected]

Elio StruyfSenior SharePoint Consultant