Archive

Archive for the ‘CQWP’ Category

How To Disable Caching In CQWP

September 17th, 2011 Abed Khooli 1 comment

The Content Query Web Part is very useful for content aggregation and roll-up across the site collection scope. It was around in the previous version of SharePoint but has been improved in 2010 as can be seen in this MSDN Blog. There are, however, some inconveniences associated with it. CQWP may have issues with anonymous access as described here. The other issue which was discussed in this thread and also mentioned (2007) in this post is related to caching.
So, you configure a CQWP and apply some filtering. You test the results and they look OK. Then, you discover that new additions or updates are not reflected instantly – not even with a forced refresh, unless you try several times. You may go back to edit the web part and find that results are reflected immediately after an edit, but that’s not a solution.
The problem is related to caching which cannot be adjusted from the user interface. There are two workarounds: either export the web part and add a property to the exported file and re-import it (as explained in the thread above) or edit the page hosting the CQWP in SharePoint Designer to add a property to the tag directly: edit the page and while the CQWP is selected, switch to code view and add
UseCache=”False”
to the

Categories: CQWP Tags:

Custom Blog Rollup Using Content Query Web Part

June 27th, 2011 Abed Khooli No comments

There are a few posts dealing with CQWP customization but most of them use the publishing pages. A few requests have been posted to customize blog posts using CQWP and there is something specific to this request: the CQWP does not output the blog post body out of the box. Before I describe the process, I should give credit to the blog post by Heather Solomon (2007, but still valid for 2010).
There are two main steps in this process: customize the ItemStyle and the CQWP. You can find the reference on adding properties to the CQWP at this MSDN article.
So, we export the CQWP and edit the line that has CommonViewFields to become Body, Note
Here, Body is the post body text and Note is its type (yes, it’s not RichHtml as you may think), but how do we know? You check the schema file at \14\TEMPLATE\FEATURES\DiscussionsList\Discuss
Now that we have the field available in the CQWP, we edit the item style. The ItemStyle.xsl file lives in the Style Library in your site collection (only there, one style library per site collection) inside the folder XSL Style Sheets (that’s easy to figure out). You download the file and open it in a text or xml editor. Here, we will copy the default style and paste it under the original (starts with – around 67 lines). Of course, we need to name our style – I replaced the first line by

in that block (close to the end of the template). Here, I am taking the first 75 characters of the clean text and added a link to see the full post.
Finally, I added the template that strips out html tags right after the closing tag of my custom template (). The removeMarkup template is available from Heather’s post toward the end and is clearly marked.
Save the xsl file and re-upload to the styles library (xsl style sheets folder). You need to publish a major version for this to work (not only check it in).
Now, you add a web part to your page based on the exported and adjusted one (under the web part groups, locate the Upload web part then select from imported web parts). Configure your CQWP and select your new item style (do not add Body; in the Description field!). If you did not have typos, you should see something similar to the above screen shot. If your itemstyle is not correct, your CQWP will not show and will give error (add ?contents=1 to the url and delete it, then roll back to the previous version of the itemstyle until you fix the custom one). See more on Heather’s blog on how to see available fields and find types etc.
Categories: CQWP Tags: blog rollup using CQWP

Horizontal News Ticker Using SharePoint 2010 CQWP

May 15th, 2011 Abed Khooli 21 comments

This post was triggered by a SharePoint forums post on creating a scroller or marquee. There are ready web parts (commercial) that provide this functionality, of course, but can we do it using the web browser alone?
Well, SharePoint has a content query web part (CQWP) that can be utilized to extract data from lists and libraries across the whole site collection and it presents entries in a standard html list format (

  • …). There is a JQuery plugin that converts this structure into a news ticker (see the liScroll website for details and download). Notice that JQuery can also use a class to identify the
      element as described on the liScroll site and one of the classes used by CQWP is dfwp-list. The steps are simple: add your own CQWP to a page (in this example, I used Blog Posts) and set it up as titles only. Add a content editor web part (CEWP) above the CQWP and edit its source. Add the JQuery library (used 1.6 in this example, make sure your master pages does not reference one already), then add liScroll plugin and its associated style sheet. Here, I ctually uploaded the three of them to a document library and referenced them from there (a must if your site is not connected to the Internet). Then, add the short script that does the scrolling. You can hide the CEWP (set chrome type to none) and also configure the CQWP (ex. give it a better title).
      Notice that you can control the scrolling speed by providing a “travelocity” parameter as explained on the liScroll website. You can also modify the CSS to change the interface.
Categories: CEWP, CQWP, SharePoint Server 2010 Tags: Marquee, News scroller,

Date Range in a Content Query Web Part

April 18th, 2011 Abed Khooli 2 comments
CQWP - date range

Content Query Web Parts (CQWP) are very powerful in aggregating site content (not limited to current site, but can span the whole site collection). They provide several customization, presentation and filtering options. They also support target audiences at the item level and can be limited to certain content types. However, date filters are not easy to configure if a date range is required (for example, the latest announcements – those in the past couple weeks).
Luckily, there is a help icon next to the Additional Filters section and it has some hints on how to set a date offset. In the illustration here, the CQWP fetches the announcements that are less than 7 weeks old (nothing special about the number 48 except it works with the test list which had few entries and most were more than 7 weeks old). Notice the -48 notation (no space) which means [Today] + [-48] days.
You can find more about advanced customization of the Content Query Web Part at: http://msdn.microsoft.com/en-us/library/aa981241.aspx