working with jquery and the cqwp - nellis...

17
Working with jQuery and the CQWP Christina Wheeler

Upload: others

Post on 28-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

WorkingwithjQueryandtheCQWPChristinaWheeler

Page 2: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

AboutMeChristinaWheeler,MCTSSharePointTrainer&ConsultantCriticalPathTraininghttp://www.criticalpathtraining.com– Blog:http://www.sharepointwheeler.com– Twitter:@cwheeler76– Email:[email protected]– PublishedBooks

• SharePoint2010FieldGuide• SharePoint2013InsideOut

Page 3: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

CONTENTQUERYWEBPART(CQWP)

Page 4: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

ContentQuery WebPart(CQWP)• No,thiswebpartisNOTdead!J• MinormodificationsmadeinSharePoint2013• Aggregatescontentreal-time• *NEW*Filterbypagenavigationterm

Page 5: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

CQWPBenefits• CQWPworksbothon-premises&O365• Instantlyupdates– Nowaitingforacrawltorun,norelianceonsearch

• Simpletouse– Intuitivewebpartproperties– Canbeusedbycontentownerstobuilddynamiccontentonpagesfairlyeasily

– DoesnotrequireVisualStudiotocreateandmaintain• Grouping– Hasagroupingfunctionalitythatthesearchwebpartdoesn’treallypossessandisusedwithdecentfrequency

Page 6: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

WhentoUseCQWP• CQWPonlyreliesonthePublishingFeaturethereforeismoreavailableonvariouslicensedO365andServerversions– ContentbySearchWebPartislicensespecificthereforenotallusershaveaccesstousingtheCSWP

• RecommendusingCQWPwhen:– Needingtodisplaysimplecontent– Notneedingcomplexqueries

Page 7: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

CQWP– PresentationStyling• ContentQueryMain.xsl– ContainsthelogicthatgeneratesthecallstotheHeaderandItemtemplatesforeachitem

• Header.xsl– Templatesthatdefinehowtodisplaytheheaders(groupby)

• ItemStyle.xsl– Templatesthatdefinehowtodisplaytheitemsreturnedfromthequery

Page 8: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

BestPractices• UsecustomXSLfilesforGroupandItemstyle• Usecustomcontenttypesforrolledupcontentforbetterrefining

• UseOverrideswhenneededtoimproveperformance

Page 9: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

UseCustomXSLFiles• CreateXSLfilesinXSLStyleLibrary– Example:CustomContentQueryMain.xslCustomItemStyle.xslCustomHeader.xsl

• Add CQWPtoapage• Export CQWPtolocalfilesystem• Open CQWP.webpart fileintexteditor

Page 10: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

UseCustomXSLFiles• UpdatethepropertiespointingtothedesiredcustomXSLstylesheet

<property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/CustomContentQueryMain.xsl</property>

<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/CustomItemStyle.xsl</property>

<property name="HeaderXslLink" type="string">/Style Library/XSL Style Sheets/CustomHeader.xsl</property>

Page 11: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

UseCustomXSLFiles• SaveandimportCQWPtothedesiredpageandconfigure

• Forreusability,addcustomizedCQWPintotheWebPartGallery

Page 12: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

WORKINGWITHJQUERY&CQWP

Page 13: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

jQuery&theCQWP• jQuerycanbeusedinvariouswayswiththeCQWP– Accordions– ModalWindows– Slideshows– InteractiveNavigationElements– Etc…

Page 14: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

ReferencingjQuery• AddreferencestojQuerylibrariesandJavaScriptfilesthrough:– SnippetsWebPart– ContentEditorWebPart(referencefile)– DirectlyinCQWPXSLtemplatefiles

Page 15: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

ReferencingjQuerydirectlyinXSLInlineScriptBlock:<xsl:text disable-output-escaping="yes"><![CDATA[ <script type="text/javascript">(your JavaScript code here) </script> ]]> </xsl:text>

ScriptReferenceBlock:<xsl:text disable-output-escaping="yes"><![CDATA[ <script type="text/javascript"src="/SiteAssets/jquery-1.9.1.min.js"></script> ]]> </xsl:text>

Page 16: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

DEMO

Page 17: Working with jQuery and the CQWP - Nellis …nellisconsultingllc.com/Resources/SPTechConSF2016Slides...• SharePoint 2010 Field Guide • SharePoint 2013 Inside Out CONTENT QUERY

Questions?ChristinaWheeler,MCTSSharePointTrainer&ConsultantCriticalPathTraininghttp://www.criticalpathtraining.com– Blog:http://www.sharepointwheeler.com– Twitter:@cwheeler76– Email:[email protected]– PublishedBooks

• SharePoint2010FieldGuide• SharePoint2013InsideOut