<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx</link><description>The Content Query Web Part (CQWP) in MOSS is one of the popular out-of-the-box Publishing components which is used in content management sites, allowing you to get results from different sources. But sometimes out of the box functionality is not enough</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1742020</link><pubDate>Tue, 24 Nov 2009 21:31:44 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1742020</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;The way to achieve this is to control the CAML query you overried in your subslassed CQWP&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1742020" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1741996</link><pubDate>Tue, 24 Nov 2009 17:13:05 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1741996</guid><dc:creator>Carl</dc:creator><description>&lt;p&gt;Can you provide more details on filtering content in content query. I have enabled the connection on content query webpart and reading the providers field values and i want to filter the content of the content query webpart.&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1741996" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1723596</link><pubDate>Tue, 15 Sep 2009 19:54:35 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1723596</guid><dc:creator>Mohamed Hachem</dc:creator><description>&lt;p&gt;Hello &lt;/p&gt;
&lt;p&gt;To achieve Orderby and where statment in content query web part &lt;/p&gt;
&lt;p&gt;you have two ways :&lt;/p&gt;
&lt;p&gt;static way writing query in the the actual webpart xml as follows:&lt;/p&gt;
&lt;p&gt;&amp;lt;property name=&amp;quot;QueryOverride&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;&amp;lt;![CDATA[&amp;lt;OrderBy&amp;gt;&amp;lt;FieldRef Name=&amp;#39;MomoOrder&amp;#39; Nullable=&amp;#39;True&amp;#39; Type=&amp;#39;Number&amp;#39; Ascending=&amp;#39;True&amp;#39;/&amp;gt;&amp;lt;/OrderBy&amp;gt; &amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Project&amp;#39;/&amp;gt;&amp;lt;Value Type=&amp;#39;LookupMulti&amp;#39;&amp;gt;Nelson&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;]]&amp;gt;&amp;lt;/property&amp;gt;&lt;/p&gt;
&lt;p&gt;Dynamic Way, is done by creating class that inherits from sharepoint content query webpart, you override &lt;/p&gt;
&lt;p&gt;protected override void CreateChildControls()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.QueryOverride = customQueryOverride;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;base.CreateChildControls();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.QueryOverride = string.Empty;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.CommonViewFields = string.Empty;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;public override void ApplyChanges()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;base.ApplyChanges();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; // LabelValue is the value of the custom label&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; // that you added while constructing webpart &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; // to had ordering or filtering value &lt;/p&gt;
&lt;p&gt;customQueryOverride= &amp;quot;&amp;lt;OrderBy&amp;gt;&amp;lt;FieldRef Name=&amp;#39;ListOrder&amp;#39; Nullable=&amp;#39;True&amp;#39; Type=&amp;#39;Number&amp;#39; Ascending=&amp;#39;True&amp;#39;/&amp;gt;&amp;lt;/OrderBy&amp;gt;&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Project&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;LookupMulti&amp;#39;&amp;gt;&amp;quot; + LabelValue + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;&amp;quot;;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Cheers &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1723596" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696072</link><pubDate>Sun, 21 Jun 2009 21:34:40 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696072</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://tinyurl.com/nuwzf4"&gt;http://tinyurl.com/nuwzf4&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696072" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696038</link><pubDate>Sun, 21 Jun 2009 16:22:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696038</guid><dc:creator>sudha</dc:creator><description>&lt;p&gt;please suggest me the approch that suits to my requirement. can you please send the sample code.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696038" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696036</link><pubDate>Sun, 21 Jun 2009 16:15:55 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696036</guid><dc:creator>sudha</dc:creator><description>&lt;p&gt;First time i am working on CQWP customization.&lt;/p&gt;
&lt;p&gt;One more question i have,&lt;/p&gt;
&lt;p&gt;How to expose the new properties like grouping and sorting.. how to use the newly exposed property in CAML query..&lt;/p&gt;
&lt;p&gt;Not able to open this link, please send the full URL.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696036" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696032</link><pubDate>Sun, 21 Jun 2009 15:39:40 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696032</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Where exactly you stuck?&lt;/p&gt;
&lt;p&gt;You just read the user&amp;#39;s properties from AD and then construct you CAML query to include that country.&lt;/p&gt;
&lt;p&gt;See this sample &lt;a rel="nofollow" target="_new" href="http://www.helloitsliam.com/archive/2007/07/03/moss2007-"&gt;www.helloitsliam.com/.../moss2007-&lt;/a&gt;–-redirect-using-profile-property-and-sharepoint-list.aspx&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696032" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696030</link><pubDate>Sun, 21 Jun 2009 15:28:51 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696030</guid><dc:creator>sudha</dc:creator><description>&lt;p&gt;Michael, i am really waiting for your answer. please help me out. &lt;/p&gt;
&lt;p&gt;thanks..&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696030" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696013</link><pubDate>Sun, 21 Jun 2009 12:57:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696013</guid><dc:creator>sudha</dc:creator><description>&lt;p&gt;Our company employees located in Geographical areas(USA,UK,INDIA).&lt;/p&gt;
&lt;p&gt;User profiles are dumped from AD to sharepoint.&lt;/p&gt;
&lt;p&gt;that has a property named as Region holds the User Region. Ex: &amp;nbsp;USA,UK,INDIA&lt;/p&gt;
&lt;p&gt;I have news Document libray containing news articles and has one field named region, which indicated this artical related to that perticular region.&lt;/p&gt;
&lt;p&gt;Ex: &amp;nbsp;USA,UK,INDIA&lt;/p&gt;
&lt;p&gt;i want to display the news articals based on loggedIN user region by pulling the region from user profile and map it with the field region of news artical located at news document librey.&lt;/p&gt;
&lt;p&gt;i want to customize the CQWP. plese help me out.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696013" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696010</link><pubDate>Sun, 21 Jun 2009 12:37:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696010</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;What are the requirements to the &amp;quot;region&amp;quot; detection?&lt;/p&gt;
&lt;p&gt;Do you want to detect it by IP - where user physically locates (but what to do in case of working over proxy or being in business trip),&lt;/p&gt;
&lt;p&gt;or you want to detect the region based on the user&amp;#39;s localizations settings?&lt;/p&gt;
&lt;p&gt;See these links &lt;/p&gt;
&lt;p&gt;1) &lt;a rel="nofollow" target="_new" href="http://www.west-wind.com/weblog/posts/334.aspx"&gt;www.west-wind.com/.../334.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;2) &lt;a rel="nofollow" target="_new" href="http://forums.asp.net/t/1052219.aspx"&gt;forums.asp.net/.../1052219.aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696010" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1696006</link><pubDate>Sun, 21 Jun 2009 12:07:34 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696006</guid><dc:creator>sudha</dc:creator><description>&lt;p&gt;i want to display the items in CQWP based on logged in user region.&lt;/p&gt;
&lt;p&gt;ex:&lt;/p&gt;
&lt;p&gt;if logged in user belongs to Middel East, i want to display Middle East related news articals to the user.&lt;/p&gt;
&lt;p&gt;user profile property holds the user Region and news artical has the field named as region.&lt;/p&gt;
&lt;p&gt;i want to map these and display the related news articles. &lt;/p&gt;
&lt;p&gt;Please help me out. thanks in advance.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696006" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1689341</link><pubDate>Tue, 21 Apr 2009 05:33:30 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1689341</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;I posted the code-snippet, what means that you need to write the additional code.&lt;/p&gt;
&lt;p&gt;1) _filterProviders - please read a commends for the &amp;nbsp;line 8. It says how to declare that variable &lt;/p&gt;
&lt;p&gt;2) providerValues &amp;nbsp;- check what filterProvider.ParameterValues returs, and create such field&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1689341" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1689338</link><pubDate>Tue, 21 Apr 2009 05:21:15 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1689338</guid><dc:creator>Tee</dc:creator><description>&lt;p&gt;Hi Micheal, I tried your code; however, I got the error when I compile it, here is the errors:&lt;/p&gt;
&lt;p&gt;The name &amp;#39;providerValues&amp;#39; does not exist in the current context&lt;/p&gt;
&lt;p&gt;The name &amp;#39;_filterProviders&amp;#39; does not exist in the current context&lt;/p&gt;
&lt;p&gt;It seems that it does not recognize these variables:&lt;/p&gt;
&lt;p&gt;providerValues&lt;/p&gt;
&lt;p&gt;_filterProviders&lt;/p&gt;
&lt;p&gt;Could you tell me what need to be fixed to eliminate these errors. Thanks for your help, here is my code:&lt;/p&gt;
&lt;p&gt;[skipped]&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1689338" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1657650</link><pubDate>Wed, 24 Dec 2008 11:16:35 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1657650</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Nope. You need either to disable the cache or don&amp;#39;t use checkout items.&lt;/p&gt;
&lt;p&gt;Actually, it&amp;#39;s not only checkout items, but items which are not published yet, are out of the CQWP results in standard mode. We had such issue before :)&lt;/p&gt;
&lt;p&gt;I found this behavior very logical. Because checked items and not published items are private items, which are in work now, and you should not expose those data in most of cases.&lt;/p&gt;
&lt;p&gt;So, just disable cache or revise your approach for shown data in CQWP&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1657650" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1657636</link><pubDate>Wed, 24 Dec 2008 07:50:37 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1657636</guid><dc:creator>Haitao</dc:creator><description>&lt;p&gt;My root CAML element is &amp;lt;Where&amp;gt;. So, the complete CAML is: &amp;quot;&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Author&amp;#39; LookupID=&amp;#39;True&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;User&amp;#39;&amp;gt;&amp;lt;UserID /&amp;gt;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;&amp;quot;. &lt;/p&gt;
&lt;p&gt;I used this CAML in a SPQuery object. Then I tried to get items from a custom list with this SPQuery object. The fact is that this CAML works perfectly to filter all the items created by the current user in both edit mode and normal mode. So, I guess this problem is something related to CQWP only.&lt;/p&gt;
&lt;p&gt;I googled lots of pages and found one post saying that the caching infrastructure of the CQWP does not cache checked-out items of individual users and we disable cache in edit mode. By following his suggestion, I set the UseCache property of the CQWP to false. This way, it works :) &lt;/p&gt;
&lt;p&gt;Now, the problem is disabling the cache of CQWP because I don&amp;#39;t think this is the right way of doing things. Do you have any ideas on this? Is there is another way of writting the CAML so that we can work around the cache issue?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1657636" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1656853</link><pubDate>Tue, 16 Dec 2008 12:14:46 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656853</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Where is your root &amp;lt;Query&amp;gt; element for CAML?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656853" width="1" height="1"&gt;</description></item><item><title>re: Subclassing Content Query Web Part to override CAML query</title><link>http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx#1656615</link><pubDate>Fri, 12 Dec 2008 16:34:32 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1656615</guid><dc:creator>Haitao</dc:creator><description>&lt;p&gt;Hi Micheal,&lt;/p&gt;
&lt;p&gt;I have created a subclass of CBQ web part and enable my CBQ&amp;#39;s subclass with the ability of using custom CAML. Recently, I want to use a custom CAML which filters all the list item of created by the current user. The CAML is like &lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Author&amp;#39; LookupID=&amp;#39;True&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;User&amp;#39;&amp;gt;&amp;lt;UserID /&amp;gt;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;The problem is, when the page is in edit mode, the CAML works perfectly. But when I exit the edit mode, it cannot returieve any item out. &lt;/p&gt;
&lt;p&gt;What probably is the problem? Can you give me any help?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1656615" width="1" height="1"&gt;</description></item></channel></rss>