Office 365 is the brand name Microsoft uses for a group of software and services subscriptions, which together provide productivity software and related services to subscribers. Office 365 offers plans providing e-mail and social networking services through hosted versions of Exchange Server, Skype for Business Server, SharePoint and Office Online, integration with Yammer, as well as access to the Microsoft Office software. There most customizable part of Office 365 is SharePoint. Many of you probably worked with SharePoint in one or another way.
SharePoint is an awesome platform, it has a lot of useful OOB features, it is usually a good idea to use Content Query Web Part or Content Search Web Part to aggregate content for end users. Both of these webparts have it is own limitations
We will use Content Query Web Part because we only need to display articles with given content type from a single site collection. Also, it provides a better user experience, because users don't need to wait until next search crawl finish.
Content Query Web Part is a part of the Enterprise Content Management (ECM) functionality in Microsoft Office SharePoint Server. It aggregates and displays list items within a site hierarchy. In addition to hierarchical query capabilities, the Content Query Web Part provides caching and query optimization for the
SPSiteDataQuery object that it contains. These optimizations have better performance than if you directly call methods of the
First of all we need to create a content that will be consumed by CQWP.
Make sure you have admin access to your Office365 site collection
Go to "Site Settings" -> "Site Collection Features".
Find "SharePoint Server Publishing Infrastructure" and make sure it is activated
Go to "Site Settings" -> "Manage site features".
Find "SharePoint Server Publishing" and make sure it is activated
Go to "Site Contents" -> "Pages" and create 5 new articles:
Select 'Body Only', we don't need anything fancy for our simple tutorial:
Don't forget to set 'Rollup Image' for an article, we will use it latter
Repeat this 5 times, we need to have some content before we can start!
Creating custom CQWP
Create a new Blank Web Part page somewhere.
Add a new Content Query Web Part to the page
Set CQWP query to the following
You will get something simmilar to
Now we need to modify CQWP markup to meet our needs:
By default CQWP use XSL style sheets from Style Library -> XSL Style Sheets
We don't want to break all other CQWP web parts on a target site collection, so we will copy this folder and update CQWP web part to use custom stylesheets. So create a copy of
XSL Style Sheetsand move it to
Style Library/Custom/Demo/XSL Style Sheets.
Now we need to make CQWP Web Part use our custom style sheets instead of standard. Export CQWP webpart and change the following properties:
<property name="Title" type="string">Custom Content Query</property> <property name="MainXslLink" type="string">/Style Library/Custom/Demo/XSL Style Sheets/ContentQueryMain.xsl</property> <property name="ItemXslLink" type="string">/Style Library/Custom/Demo/XSL Style Sheets/ItemStyle.xsl</property> <property name="HeaderXslLink" type="string">/Style Library/Custom/Demo/XSL Style Sheets/Header.xsl</property>
Make sure you work on a root site collection, otherwise you will have to adjust your xsl-links accordingly.
Upload the changed web part to Web Part gallery (Site Settings -> Web Parts):
Replace the old CQWP webpart with our new one
CQWP is an awesome way to aggregate content using OOB features of SharePoint, it can provide an awesome user experience, but it may be
slower that Content Search Web Part when you have lots of content.