1 / 33

Code Camp NZ 2011

Code Camp NZ 2011. # CCNZ. www.mscommunities.co.nz. Customising Content Query Web Part (CQWP) in SharePoint 2010. Chakkaradeep ( Chaks ) Chandran SharePoint Consultant Microsoft New Zealand chaksc@microsoft.com http://www.chakkaradeep.com http ://blogs.msdn.com/chaks @ chakkaradeep.

dillon
Télécharger la présentation

Code Camp NZ 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Camp NZ 2011 #CCNZ www.mscommunities.co.nz

  2. CustomisingContent Query Web Part (CQWP) in SharePoint 2010 Chakkaradeep (Chaks) Chandran SharePoint Consultant Microsoft New Zealand chaksc@microsoft.com http://www.chakkaradeep.com http://blogs.msdn.com/chaks @chakkaradeep

  3. Session Objectives and Takeaways This session does not cover: • DataView Web Parts • Extending CQWP (C# Coding) • SharePoint Designer 2010 This session covers: • CQWP Basics • Anatomy of CQWP • CQWP Properties • Customizing CQWP • Tips & Tricks • CQWP in WCM • More Demos….

  4. Content Editor Web Part

  5. XML View Web Part

  6. List View Web Part

  7. Content Query Web Part

  8. What is CQWP? • Displays a dynamic view of content on a page • CQWP can be configured to retrieve items from: • Single or Multiple List(s) • Single site or Sub-sites • Entire site collection

  9. What is CQWP? • Centralize the content in the presentation layer • Ability to Filter, Sort, Order and Group results (Content Rollup) • Used in: • Content Management • Publishing • Content Delivery Scenarios

  10. Using CQWP – Getting Started • Requires Publishing Features to be activated

  11. Using CQWP – Filtering & Sorting

  12. Anatomy of CQWP • CQWP uses property settings and CAML to construct the query • Few available through tool pane • More advanced properties available and requires modifying the web part file • Once modified, you can re-import or even upload the modified file to the web part gallery • SPSiteDataQuery class to query the SharePoint site to gather results

  13. Anatomy of CQWP

  14. ContentQueryMain.XSL • Receives all the content, parses it, and sends appropriate pieces to the ItemStyle and Header templates. • Maintains the structure of the Content By Query Web Part. • Stores data retrieved when querying content in the path /dsQueryResponse/Rows/Row.

  15. ItemStyle.XSL • Contains templates that define how to display an item. • These templates receive and process one row of data at a time, ensuring that the style and data in the item rows is consistent.

  16. Item Styles <xsl:template name="TitleOnly" match="Row[@Style='TitleOnly']" mode="itemstyle"> <xsl:variable name="SafeLinkUrl"> <xsl:call-template name="OuterTemplate.GetSafeLink"> <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="DisplayTitle"> <xsl:call-template name="OuterTemplate.GetTitle"> <xsl:with-param name="Title" select="@Title"/> <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/> </xsl:call-template> </xsl:variable> <div class="item link-item"> <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/> <a href="{$SafeLinkUrl}" title="{@LinkToolTip}"> <xsl:if test="$ItemsHaveStreams = 'True'"> <xsl:attribute name="onclick"> <xsl:value-of select="@OnClickForWebRendering"/> </xsl:attribute> </xsl:if> <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'"> <xsl:attribute name="onclick"> <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/> </xsl:attribute> </xsl:if> <xsl:value-of select="$DisplayTitle"/> </a> </div> </xsl:template>

  17. demo Custom ItemStyles

  18. Slots • Depending on the scope of your query, select one or more site or list columns • Column from a particular group – Column [Group]

  19. Default functions in ContentQueryMain.xsl

  20. Properties that modify UI and Behavior

  21. Properties that modify UI and Behavior

  22. Properties that do not override behavior

  23. Additional Filters – “context of the current article” • PageFieldValue • Dynamically replaces the value for the filter with the current page’s field value. • PageQueryString • Looks at the URL query string for a value to use in the Query. Courtesy: http://blogs.msdn.com/ecm

  24. Before you start Getting the most out of this web part requires consideration and planning of your content management needs up front

  25. demo Custom Styles

  26. Styles Summary ContentQueryMain.xsl ItemStyle.xsl

  27. Demo Summary • Customising default Style • FixedImage • Customising ContentQueryMain.xsl • Customising ItemStyle.xsl • Custom HTML rendering code

  28. Tips and Tricks • Use consistent site columns for content filtering. • ALL XML inside a <property/> tag must be enclosed in a <![CDATA[ ]]> block. • Upload to the web part gallery a pre-configured CQWP. • Expose custom fields via AdditionalFilterFieldsto allow for modification via browser

  29. Tips and Tricks • Use ListsOverride property to query against other list types • If you need to query against >1000 lists you can add the MaxListLimitattribute to the ListsOverrideproperty. • By default this is set to 1000 • There is a performance trade-off here • The CAML query can have any number of filter fields and values (tool pane is limited to three)

  30. Tips and Tricks • Only list templates available at the site root are enumerated. • When setting properties requiring use of the column’s internal name remember a space is represented as _x0020_ : <property name="CommonViewFields" type="string"> Project_x0020_Title, Text;Project_x0020_Owner, Text;ProjectNotes, Text</property>

  31. Tips and Tricks • When filtering on Yes/No data type use the value “1” and “0” • To render HTML and not raw tags set the disable-output-escaping attribute to true: <xsl:value-of select="@InternalName" disable-output-escaping="yes"/>

  32. Thanks to our sponsors and partners! Sponsor Premier Partners Associated Partners Supporting Partners

More Related