Paging Content Query Web Part

, , ,

We all know the Content Query Web Part shipped with MOSS 2007. It is so far the best content aggregation solution available. While it is extremely flexible and allows you to define your own presentation layer, it lacks some basic aggregation features like results paging and dynamic content filtering. While Andrew Connell has presented recently a nice approach to achieve last one, I have decided to focus on the paging functionality.

Customizing the Content Query Web Part isn't always as easy, as many of us SharePoint developers would like it to be. Next to some general programming skills and knowing the SharePoint object model you have to do some digging on how the CQWP works and where it allows you to plug in. One of the greatest example of customizing the CQWP is the Enhanced Content Query Web Part by Ishai Sagi. If you're interested in extending the CQWP it is definitely a nice point to start. Back to the paging…

I don't think I need to explain the idea of paging results: a Web Part supporting paging should give you at least the possibility to define how many items you want to display per page.

eqcwp

The Pager

I took the requirements a step further: I have decided to detach the Paging functionality from the CQWP so that if you don't want it at a particular place, you can simply "turn it off" and use the regular CQWP functionality. To provide that flexibility I have decided to use the concept of connectable Web Parts and let the CQWP send the required paging information to the Pager Web Part. The data displayed by the CQWP would change upon selecting a page. Two problems arise at this point.

First of all the pager would have to be a consumer and provider at the same time. Based on the retrieved paging data (how many pages are there, and which page are we currently on) it would render the pager. After selecting a page it would provide this information to the CQWP so it can modify the displayed data.
While a Web Part can be both consumer and provider at the same time, it can't be done to retrieve and provide data to one and the same Web Part at the same time.

Another issue arises when considering accessibility. By providing the current page information using the Web Part Connection concept, there is now way of accessing the particular results page by using the URL only. The current page information is being stored in the interface which both Web Parts implement, but you cannot persist it in the URL.

In order to solve both issues, I have decided to make the Pager Web Part a receiver and let the CQWP use a query string parameter to determine the current page. By placing that information in the interface both Web Parts implement, the CQWP knows which variable contains the information about the current page and the Pager Web Part knows which variable it should use for rendering the links to particular pages.

As for the presentation layer I have decided to leverage the concept presented by the CQWP and support XSL. The Pager itself produces XML which can be modified to suit any chrome using XSL.

ecqwp_pagerxml

Extended Content Query Web Part

The Extended CQWP supports paging by using a query string parameter. After setting the basic properties: number of items per page and the name of the query string parameter which contains the current page number, the paging is on.

ecqwp paging settings 

ecqwp paging on 

I will try to provide a 'How I did it' with some more details on the Web Part next week. In the meanwhile you can download the wsp containing both Web Parts and check them out.


Possibly related posts

158 Responses to “Paging Content Query Web Part”

  1. Diana Says:

    Hello,
    I placed both webparts on a page and connected them. But the ExtendedContentQueryWebPartPager shows "no items found". What can I do to solve this?
    Thanks for your answer.

  2. Waldek Mastykarz Says:

    Hello Diana,

    Thank you for your feedback. I've noticed that the connection doesn't work properly if you add both Web Parts at the same time. After I've added the ExCQWP first, published the page and then added the Pager and setup the connection it all worked properly. If you're in a hurry, you can use this approach. Unfortunately I can't promise when I will have time to come up with a solution to this issue.

    Good luck!

  3. Bart de Jonge Says:

    Hello Waldek,

    I tested your Paging content query web part and all works fine. nice work btw!!
    Could you please make the source available at codeplex because I want to edit it a litle. If you browse to the page with the webparts without a request variable the pager doesn't display anything. maybe I can add a default value for the variable.

    Thanks Bart

  4. Waldek Mastykarz Says:

    Hi Bart,

    Thank your for your feedback. I have added the default value as well, yet didn't have time to publish it yet. I will try to post the source as soon as possible.

    Waldek

  5. Bart de Jonge Says:

    Hi Waldek,

    that was really fast :-)
    thanks and keep up the good work.

    Bart

  6. Nuno Leong Says:

    Hi Waldek,

    I think you have a bug on the paging calculation. If you have, for example, 17 items, showing 5 items per page, we only get 3 pages instead of 4.

    We've checked with .NET Reflector, and this seems wrong:
    In the ProcessItems method of the ExtendedContentQueryWebPart class you are calculating the number of pages with Math.Round:

    this.numPages = (int) Math.Round((double) (((double) dt.Rows.Count) / ((double) this.ItemsPerPage)));

    (the result should be 17/5 = 3.4 and this should ceiling to 4, instead we get 3)

    Should't Math.Ceiling be used instead of Math.Round?

    Nice work, by the way!

    Kind Regards,
    Nuno Leong and André Cunha

  7. Waldek Mastykarz Says:

    Hi Guys,

    Thank you for your comment and research. I really appreciate it. You're absolutely right: while focusing on the functionality I have totally forgotten about rounding the division in the right way. As you've probably seen in my previous comment, I'm planning to share the source code as well. I will definitely include the fix.

    Thanks again,

    Waldek

  8. Diana Says:

    The pager webppart is connected to the CQWP, but now we cannot filter the CQWP anymore because only one connection to the CQWP is possible. It would be great if the CQWP could have more than one connection in a future release. Thanks.

  9. Bart de Jonge Says:

    Hello Waldek,

    Could you please send me the sourcecode of your extended CQWP. I work at orbitone and we want to merge the enhanced CQWP and your webpart. We already added an additional filter to the enhanced CQWP to use request variables. When we finish we will share the code.

    thanks Bart

  10. Nir Says:

    Hi
    Thanks a lot ! this realy save me time.
    if you see "no items found" make sure that :
    1) Items per page is not 0
    2) you set the querystring propety
    3)you pass a value to that query string (e.g pageNum=1)

    Thanks again,Nir

  11. André Cunha Says:

    Hello,

    Nice work, are you thinking on releasing the source code and allow other to contribute with new functionalities? I beleive this component is very usefull and many people (including myself) want to use it and be able to include some custumizations and develop new functionalities.

    Best Regards,

    André Cunha

  12. TJ Says:

    Landed here from another Google. Just proves your excellent post content :-)

    Any how, after grabbing this extended CQWP I have 2 questions.

    1. I had to change in web.config the trust level from WSS_Minimal to WSS_Medium. In figuring out what to do I found that trust levels can be configured in the manifest.xml. Seeing you haven\'t put anything in the manifest have you in your own environment changed the trust level to Medium?

    2. After sorting the trust levels and actually seeing the webparts on my page the Query Web Part has an initial issue. \"Unable to display this Web Part. To troubleshoot…..\"
    I have played with configuring the web part but nothing changes.

    Also thanks for the pointer to here from the other comment. Funny how landed here any way.

  13. Waldek Mastykarz Says:

    In my development env. I use the Full trust. You should give it a try and check whether it will help you.

  14. Lucio Says:

    dear all,

    I cannot connect two WP.

    help me, pls

  15. Lucio Says:

    ok, i've aready set up it right
    thanks

  16. TJ Says:

    Waldek.

    I'm trying to inherit from the CQWP just as you do.

    It works. But an error occurs occasionally when setting values in the tool pane and I can't figure out why. I can't replicate it step for step yet but the error is "failed to load view state". It hints at the controls being different. But the controls in the tool pane are created in the createchildcontrols.

    Any tips on how I can figure out what my problem is or what I should avoid doing?

  17. Waldek Mastykarz Says:

    Could you mail me the code? I could try to look at it.

  18. d-boy Says:

    Thanks W. for your solution.
    Do you also have a good solution for having the paging functionality in the same webpart??? Didn´t manage to merge the two you have created.
    Thanks man..

  19. Waldek Mastykarz Says:

    Could you perhaps describe your problem a bit more? Unfortunately I've got no all-in-1 solution for paging using the CQWP but you could do it easily by merging the code. I don't know how experience you are as developer but it wouldn't be difficult.

  20. Ross Says:

    Hi Waldek,
    ive deployed your solution files but when i try to preview the webparts, then i got error "An error occured when previewing the Web Part. "

    what can be the reason

    Thanks

  21. Waldek Mastykarz Says:

    Hi Ross,
    I'm not really sure whether the Preview works correctly. Have you tried putting both web parts on a publishing page? It should work there.

  22. Hugh Valentine Says:

    Hi is the source code wsp and actual wsp on codeplex different versions? Perhaps it should be updated to reflect this.

  23. mdarwish Says:

    hi Waldek,
    did you put the source code?

    thanks in advance

  24. Waldek Mastykarz Says:

    I'm going to update the .wsp. In the meanwhile you can build a new WSP using the updated source code.

  25. Waldek Mastykarz Says:

    mdarwish: the source code is available on CodePlex, see the Tools section for the link

  26. TRUNGPV Says:

    Help me.
    I try to deploy whole day.
    But I always receive error: "No Items found"

  27. TRUNGPV Says:

    I have done
    Thanks you so much Waldek

    You save my life

  28. Hdevelop Says:

    Hello :)

    I have some problems in order to view itmes :
    1-I am using a custom list with announcment content type.so when I configure the content query webpart and then at the number of items per page it gives that error :

    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

    But when I try the same setting on a normal content query webpart ,it works fine .
    So may I ask for help on how to solve this ..please :)

    Thanks :)

  29. Waldek Mastykarz Says:

    @Hdevelop: the error you have mentioned has most of the time something to do with XSLT. Have you modified anything there by any chance?

  30. Hdevelop Says:

    no none …its the same xslt which works on the normal content query webpart but not on the extended one.

  31. Waldek Mastykarz Says:

    @Hdevelop: that's strange. Anything else you've changed?

  32. Hamza Farooq Says:

    hey i got a requirment of doing the paging plus some timer thing so content keeps scrolling line by line showing the rollup image along with it. before i try to reinvent the wheel , have anyone done this thing before

  33. Amir Says:

    Hey, I don´t understand how to connect the two webparts.
    I klick on the Open the tool pane on the pager webpart but i can´t find where to connect to the CQWP.

  34. Waldek Mastykarz Says:

    @Amir: You connect the CQWP to the pager just as you would connect any other two Web Part. Edit the Page, then from the Web Part edit menu choose Connections and connect it to the pager.

  35. Amir Says:

    Never mind i got it to work, for anyone else as blind as me…the connection link is in the edit meny of the pager webpart. :-)

  36. Amir Says:

    Thanks for the answer ! I posted the same answer at exactly the same time. What are the odds of that happening :-)

  37. Stéphane Says:

    Hi !
    I'd like to test your webpart but I am still faced to an error message : "unable to add selected web part(s) extended content query web part : cannot import this webpart".

    What I have to do to fix it ?

  38. Waldek Mastykarz Says:

    @Stéphane: Can you confirm that the solution has been deployed correctly? Additionally you could try to disable custom errors in web.config to get more background information on the error that you're facing. The web part work on a Publishing Site only: can you confirm that you're activating the Feature on a Publishing Site?

  39. Dada Says:

    After I set "Item per page:" it return "Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator." How to fix it?

  40. Stéphane Says:

    Hi,
    Thanks for your reply..
    After changing the trust to WSS_Medium, it works !
    Thanks a lot
    Good job !

  41. Waldek Mastykarz Says:

    @Dada: If you've made any changes to the XSLT that's probably what's causing the error. I'd suggest you carefully examine your XSLT and check whether everything has been done correctly.

  42. Waldek Mastykarz Says:

    @Stéphane: great to hear it's up and running :D

  43. Angelo Says:

    Hi, after I set "Page Library" in "list type" it return "Unable to display this Web Part. To troubleshoot the problem…." if I set another kind of list, everything works fine… but I need "page library" :(

  44. Andrew Says:

    Hi, great job.
    I found one issue. Paging doesn't work for anonymous user. How can I fix it?

  45. Waldek Mastykarz Says:

    @Andrew: could you provide some more information on the issue that you're experiencing? I've been using that approach myself in many WCM solutions targeting anonymous users and never had any problems.

  46. Andrew Says:

    I found what was the problem. I turn on caching profile for anonymous users in site settings.
    Once again – great job.

  47. Waldek Mastykarz Says:

    @Andrew: Great to hear it all worked out. Thank you very much, I appreciate it.

  48. Ali Says:

    Hi Waldek
    Getting error while deployment.
    Can u send me deployment steps ??

    "The "ExtendedContentQueryWebPartPager" Web Part appears to be causing a problem. Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed."

  49. Waldek Mastykarz Says:

    @Ali: how did you deploy the Web Part: to bin or to GAC? What trust level did you set in your web.config?

  50. Ali Says:

    Hi waldek,
    It is working fine when i set the trustlevel to meduim.
    I have added a New Content Query webpart and ExtendedQuery webpart on the page.
    But i dont now how can i connect them.
    The option "get paging data From" is disabled.

    Can u help me to achive my goal.

    thanks for your quick response

  51. Waldek Mastykarz Says:

    @Ali: You need the Extended CQWP and the Extended CQWP Pager in order to do paging of the query results. HTH

  52. Steve Says:

    Hi,

    After deploying to the GAC I'm off. Can you give me a clue on the data that needs to be entered in to the web part tool part for Common View Fields?

    I'm sure its obvious but I keep getting the "There is a problem with the query…" message.

    Many thanks

  53. Waldek Mastykarz Says:

    @Steve: CommonViewFields is an optional property of the CQWP which allows you to include fields in the output other than the default Title, Description, Link, Image, etc. The required format is InternalName1,Type1;InternalName2,Type2, eg. Title,Text;PublishingPageContent,HTML
    And as for your error: you should have a look at my latest post about debugging the CQWP. It might give you some more idea about the errors you're getting: http://blog.mastykarz.nl/debugging-content-query-web-part/

  54. david Says:

    Hi,

    I've some troubles with the pager webpart. I see the error message : "no items found". I display 5 items per page and I insert Enhanced CQWP before the pager webpart.

    Thanks to help me.

  55. Waldek Mastykarz Says:

    @david: Have you connected both Web Parts correctly? Any more details you could provide, like: whether the Web Part works correctly without the pager and whether you checked that it's not because of the Pager's XSLT?

  56. Sireesh G V Says:

    Hi
    we have a page where I connected the three list webparts and we are implementing the item level security. But the issue is Iam not able to see the items in the connected webpart though the item exists. When I go to the list page or the view which is connected, I am able to see the items there with my credentials.

    Can you help me out in digging this issue. I need to resolve this ASAP.

    Thanks
    Sireesh

  57. Sireesh G V Says:

    I forgot to mention that I have permission on those items. But still not able to view those items.

  58. Sunanda Yalamanchili Says:

    Hi,
    I get this error when I add Extended content Query webpart to my page. However pager webpart loads properly in the page.
    i set trust level to Medium in web.config
    Please help me resolve this issue. I need to implement paging for my cqwp
    " Error Rendering Control – g_c4962cf9_4d20_4e0b_9806_e3617e27d3aaAn unhandled exception has occurred.
    Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
    Thanks,
    Sunanda

  59. Waldek Mastykarz Says:

    @Sireesh G V: does your question refers to the standard List View Web Parts or the Content Query Web Part?

  60. Waldek Mastykarz Says:

    @Sunanda Yalamanchili: as far as I can tell you: try to set the trust level to Full. The Extended CQWP I shared is a dev code as was never meant to be used in production (it's also not supported that way). If it works and it's something that suits your needs you could pick it up to create a supported web part out of it on your own.

  61. Sireesh G V Says:

    Hi I add the standard list view webparts to the page.

  62. ramzi Says:

    Hi,
    big thanx for your article and your ECQWP. I have used your webpart in a site with variations. when I publish a page containing the ECQWP (using an administrator account) in the principal language the mirroring effect is achieving correctly in other languages (I have the ECQWP and its pager which work correctly). However, in anonymous access mode I get correctly the EQWP and its pager in the principal variation but for other variations, the pager cannot retrieve the pages. I have tried to add from scratch the ECQWP but i have the same problem with the pager web part.

  63. Waldek Mastykarz Says:

    @ramzi: first of all, have you checked that the Web Part is retrieving the pages from the right site? Secondly: have you published the pages you want to aggregate? If there is no published version you might not see them in the aggregation results.

  64. ramzi Says:

    Hi,
    thank you very much. the problem concerns the publishing status of the pages. So I have approved the pages and there is no problem now. thank you very much.

  65. The Ghost Is Me Says:

    Hello Waldek,

    I would like first to thanks you for your ECQWP.

    I don't have big information on webpart but. So, i don't know life cycle of webpart.
    In fact, I want to personlize a webpart to get refreshment after an event (click on button added to the same webpart).
    Which method enable the webpart to reexcute the query !

    We have developped a custom webpart that override some methods such as onLoad(), CreateControls()… but the problem is that when the attributes are modified after first load (applying first valued), the webpart don't apply the new values.

    10x

  66. Waldek Mastykarz Says:

    @The Gost Is Me: you mean you would like to have a CQWP with server controls? To be honest it's the first time I hear such case. Could you share any more details about your requirements? I'm really interested in it and curious if CQWP is the right thing for you to use.

  67. The Ghost Is Me Says:

    Hi,

    this link presents my need
    http://img23.imageshack.us/img23/592/serverextendedcqwp.jpg

    thanks,

  68. Waldek Mastykarz Says:

    @The Gost Is Me: Why won't you then create two controls: one to do the filtering and put the selection in the query string, and another (CQWP) to grab the filter selection from the query string parameters and include it in the query to display the proper results? Seems a lot easier than modifying CQWP to include controls. Additionally it will allow you to persist the state of the selection so that if a visitor sends the URL to someone else, they will see exactly the same page instead of the default data.

  69. Pager does not work Says:

    Hi Waldek,

    i appreciate your quick response.

    I have deployed ECQWP through GAC. I got the ECQWP working and was able to connect the pager. But I keep getting no items found for the pager no matter what i do.

    I need to resolve this very quickly.

    Thanks

  70. abulut Says:

    Hi Waldek,

    I have deployed ECQWB in GAC and had it working except for paging, I was also able to connect them. But pager keeps displaying "no input found". I appreciate your help.

  71. Waldek Mastykarz Says:

    @abulut: Have you checked with the comments above? Perhaps one of them contains a solution to your problem?

  72. David Says:

    Hi, I have the same problem as abulut, I successfully deployed the 2 web parts, but ECQWPP keeps displaying "No items found" no matter what I do. I have a Site in Spanish.
    I hope you can help me.

  73. Waldek Mastykarz Says:

    @David: have you checked with the comments above to confirm that your problem doesn't resemble one of those described earlier?

  74. Tim Allison Says:

    I have successufly installed your ECQWP parts. I have a requirement to have two of these on a page. However, the default XSLT breaks the other paging by removing the URL string. How do I keep the entire URL and only replace with the new page number so the second set of parts still function.

  75. Waldek Mastykarz Says:

    @Tim Allison: As far as I can see it in the Pager's code the query string is included in the XML output (Pages/QueryString) but is being skipped in the XSLT. You could fix this by modifying the Pager's XSLT and including the value of the QueryString in the pages links.

  76. Malrok Says:

    Hi Waldek,

    I am trying to apply current user filter to custom query from ms sql 2000. But if custom sql statement have any function like substring or table Alias, i get error:

    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

    Without any function, table Alias it work fine.

    Any ideas? Thanks!

  77. Waldek Mastykarz Says:

    @Malrok: I think your question is a bit off-topic. I suggest you try to ask at http://mssharepointforums.com. Perhaps someone there had a similar problem and knows the answer.

  78. Sander Says:

    Hi Waldek,
    Really great webparts!
    However I have 2 questions:
    1 – why don\'t I get a querystring like ?page=1
    Do I need to do anything extra? If I add ?page=1 manually to the URL it works like a charm. Paging stuff is displayed and fully functional. Problem is that the querystring isn\'t added to the url
    2 – I have a site where we put a querystring to the URL. Can your webparts handle this?
    E.g we have an URL: mysite:9000/MySite/Page/News.aspx?m=78
    I cannot get your pager webpart working on this site (not even manually)

    Thnx!

  79. Waldek Mastykarz Says:

    @Sander:
    1) You mean in the pager links? Those are XSLT based so if something doesn't work as you would expect it to, you can fix it by simply editing the XSLT.
    2) Using query string shouldn't be a problem. The only thing I can imagine is your site using the same query strings as the CQWP.

  80. Brendan Says:

    Hi Waldek,

    I have deployed and connected the 2 web parts on a publishing site, but keep getting "No Items Found" message displaying in the pager web part.

    When I tick the Display XML option in the properties of the Pager web page, there is no XML dispalyed.
    According to a previous post
    if you see "no items found" make sure that :
    1) Items per page is not 0
    2) you set the querystring propety
    3)you pass a value to that query string (e.g pageNum=1)

    I have done 1 & 2 and the correct no. of items are displayed in the ECQWP. How can I ensure that a value is being passed to the query string?

    Thanks,
    Brendan

  81. Waldek Mastykarz Says:

    @Brendan: 1) Have you read all the above comments to see if your case hasn't been already solved?

    2) Have you added by any chance both Web Parts at one time? I noticed that in some situations the Pager doesn't work. Removing it, and readding seems to solve the issue.

  82. Brendan Says:

    Waldek,

    I added the web parts separately, but still get the no items found message.
    Removing and adding the Pager web part doesn't work either.

  83. Waldek Mastykarz Says:

    @Brendan: Is it only the pager that you're getting issues with, or do both Web Parts fail to work?

  84. Brendan Says:

    Just the pager. The Extended CQWP works fine.

  85. Waldek Mastykarz Says:

    @Brendan: That's weird indeed. The only thing I could think of, is that you download the source code and try to debug it in your environment.

  86. Nithi Says:

    Hi why my page display like this
    .1
    .2
    .3
    >>

    How can i change to display as follwing
    1 2 3 >>

    Thanks
    Nithi

  87. Waldek Mastykarz Says:

    @Nithi: You can use CSS to make the list items (li) display in-line (display: inline).

  88. Sibai Says:

    Well Done Waldek , you save our times :)
    I got both CQWP with pager configured and load the data , but the issue is the guery string doesn't pass a value to the pager , but if i hardcoded the ?page=1 it will work fine and the pager will get the page counts and everything is fine!! , so what is the issue??
    Thanks

  89. Smruti Says:

    Enhanced content query is not returning any results

  90. Smruti Says:

    Can anyone please tell me how did you make the pager web part work..its always telling "Item Not Found"….Extended content query web part though is working like a charm

  91. Smruti Says:

    Nithi or Sibai ..can u plz tell me how did u make it work

  92. Waldek Mastykarz Says:

    @Smruti: Have you checked will all the previous comments, if the issue that you're experiencing hasn't been solved there?

  93. Smruti Says:

    Hi Waldek..Thanks for replying.. Yes i studied all the above comments and have tried them all .. I also tried to set the querystring as Page=1, pagenum=1 etc….but pager web part doesnt work at all…Extended CQWP works fine now … I had to change trust level= full to make it work..Can you please tell me if any configuration is needed…..i made the necessary web part connections also..Its kinda urgent so i dint want to delve into coding ………..i dont know how sibai and nithi have been able to make it work….please help me..

  94. Mohammad Akilan Says:

    Dear Waldek,

    I've downloaded the .wsp file, Can you please provide me with the steps of how to deploy your solution?

    it's too much appreciated.

    Thank you in advnace,,,

    Regards,
    Mohammad Akilan.

  95. Suresh Kumar Says:

    Hi Mohammed,
    Just do the following steps:
    1.Download the .wsp file
    2.Put the file in ..12/bin/
    3.Run this command "stsadm -o addsolution -filename ExtendedCQWP.wsp
    4.Goto Central Admin->Operations->Solution Management
    5.Deploy the ExtendedCQWP.wsp file(Specify the web application)
    6.Goto your sharepoint site settings->Site collection feature->Activate the ExtendedCQWP.wsp
    7.Now the Extended CQWP & Extended CQWP Pager webpart is added in webpart gallery.
    8.Just add the webparts(Both ECQWP & Pager) in your page where you need.
    9.Connect the webparts(Click the connections(next to modify shared webpart).
    10.In Extended CQWP ->Modify shared webpart->Data view ->Query string variable(Type "page")
    11.In "items per page" give the value more than 0.
    12.Publish the page
    13.At first time just append "?page=1" in url,then only it will work.

    If u need more info..just go thru the above thread.

  96. Brendan Says:

    Good one Suresh. Worked for me when I appended "?page=1" in the URL :)

  97. Suresh Kumar Says:

    Hi,
    I'm struggling to display the Attached Documents(Announcements List) in Extended CQWP.is it possible in ECQWP?Pls let me know.It's very urgent.

  98. Waldek Mastykarz Says:

    @Suresh: The ECQWP uses exactly the same XSLT as the CQWP so it shouldn't be any different than while using the standard Content Query Web Part.

  99. Suresh Kumar Says:

    Thanks Waldek.

  100. Murali Mohan Says:

    Dear Waldek Mastykarz,

    Thanks for the nice work. I am using this web part all over the project. I am facing lot of problem while the page is checked out and submit for approval, i am getting the below messages in the logs. Please help me as soon as possible i am in trouble bcoz of that messages.

    12/21/2009 21:53:27.84 w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium Potentially excessive number of SPRequest objects (17) currently unreleased on thread 21. Ensure that this object or its parent (such as an SPWeb or SPSite) is being properly disposed. Allocation Id for this object: {939D417D-ACF2-42B2-8AAB-FC741542CB7E} Stack trace of current allocation: at Microsoft.SharePoint.SPRequestManager.Add(SPRequest request, Boolean shareable) at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) at Microsoft.SharePoint.SPWeb.InitializeSPRequest() at Microsoft.SharePoint.SPWeb.EnsureSPRequest() at Microsoft.SharePoint.SPWeb.get_Request() at Microsoft.SharePoint.SPWeb.InitWebPu…
    12/21/2009 21:53:27.84* w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium …blic() at Microsoft.SharePoint.SPWeb.get_ServerRelativeUrl() at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl, Boolean includeQueryString, Boolean canonicalizeUrl) at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl) at Microsoft.SharePoint.SPWeb.GetFolder(String strUrl) at Microsoft.SharePoint.SPList.get_RootFolder() at Microsoft.SharePoint.WebPartPages.BaseXsltDataWebPart.get_RootFolder() at Microsoft.SharePoint.WebPartPages.BaseXsltDataWebPart.ResolveMondoCAMLParamValues(XsltArgumentList argList, BaseDdwRuntime runtime) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.ResolveParameterValuesToXsl(ArgumentClassWrapper argList) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform() a…
    12/21/2009 21:53:28.25* w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium …rocHint(Int32 hint) at Microsoft.SharePoint.SPSite.OpenWeb(Guid gWebId, Int32 mondoHint) at Microsoft.SharePoint.SPSite.OpenWeb(Guid gWebId) at Microsoft.SharePoint.Publishing.CachedArea.GetIdentityWeb(Guid webId, SPSite elevatedSite, Boolean isSuperUser) at Microsoft.SharePoint.Publishing.CachedArea.GetSuperUserIdentityWeb(SPSite site) at Microsoft.SharePoint.Publishing.CachedArea.GetCrossListQuery(SPSiteDataQuery query, SPWeb currentContext) at Microsoft.SharePoint.Publishing.CrossListQueryCache.GetSiteData(CachedArea cachedArea, SPWeb web, SPSiteDataQuery query) at Microsoft.SharePoint.Publishing.CrossListQueryCache.GetSiteData(CachedArea ca) at Microsoft.SharePoint.Publishing.CrossListQueryCache.GetSiteData(SPSite site, String webUrl) at Microsoft.Sh…
    12/21/2009 21:53:28.25* w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium …arePoint.Publishing.CrossListQueryCache.GetSiteData(SPSite site) at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.IssueQuery() at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.GetXPathNavigator(String viewPath) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PerformSelect() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.DataBind() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.EnsureDataBound() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.CreateChildControls() at Imtech.SharePoint.WebParts.ExtendedContentQueryWebPart.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Cont…
    12/21/2009 21:53:28.25* w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium …rol.PreRenderRecursiveInternal() at System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(…
    12/21/2009 21:53:28.25* w3wp.exe (0×0868) 0×0310 Windows SharePoint Services General 0 Medium …HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr) at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)

  101. Waldek Mastykarz Says:

    @Murali: as you can see in the stack trace this messages are a part of the SharePoint API and have nothing to do with the extensions that I built on top of the Content Query Web Part. Please note that the log messages that you see are simply warnings, meaning that not necessarily there is something wrong with your site and the way it uses memory.

  102. Kambiz N. Says:

    Thanks to you.
    I've a BDC which display it by Business Data List Web Part. But it seems does not support paging. How could I connect BDC to Content Query Web Part, so could have paging with extended version of it.

    Thanks

  103. Waldek Mastykarz Says:

    @Kambiz: I don't think you should use the Content Query Web Part as a pager for your BDC Web Part. Instead you should create a new Web Part for that particular purpose.

  104. ÁghyBlog » links for 2009-06-08 Says:

    [...] Paging Content Query Web Part We all know the Content Query Web Part shipped with MOSS 2007. It is so far the best content aggregation solution available. While it is extremely flexible and allows you to define your own presentation layer, it lacks some basic aggregation features like results paging and dynamic content filtering. (tags: sharepoint2007 content-query webpart customize) [...]

  105. Dee Says:

    After spending ages to get this to work realised the wsp should really deploy to the GAC as modifying the TRUST setting in web.config yields unpredictable results. I can now see the content in the ECQWP and the page numbers in the Pager, but only in page edit mode :-(, the minute I exit page edit mode the ECQWP shows the "no items" message and the Pager is blank :-(

  106. Phodchara Says:

    Is it work on WSS3.0? IF not, How to do that on WSS3.0?
    Thank you
    Phodchara

  107. Waldek Mastykarz Says:

    @Phodchara: The Content Query Web Part is available with the SharePoint Server only. If you want a similar solution for WSS, you will have do develop it yourself.

  108. Duarte Says:

    Random results. Sometimes the ECQWP gets all items I am querying, but sometime sonly 45. I spent hours finding for a solution for this any ideas?

  109. share2010 Says:

    i am working on Sharepoint 2010 i have deployed this webparts but it giving me error while adding into site page 'can't import this web part' ,let me know how to solve this issue..

  110. Waldek Mastykarz Says:

    @share2010: have you read previous comments to see if anything reported there resembles your scenario?

  111. Panoone Says:

    Hi Waldek,

    What's the simplest way to modify the solution to get it to deploy to the GAC instead of the app bin?? I really need to get around this trust issue for our public-facing sites.

  112. Panoone Says:

    Ah…got it. Change DeploymentTarget="GlobalAssemblyCache" and add the assembly details.

    But will it work…?

  113. Waldek Mastykarz Says:

    @Panoone: yep, that's the one. It should work.

  114. Panoone Says:

    Hi Waldek,

    I have provided installation and configuration steps in the Codeplex discussions as it seems a few people have got stuck by not following the correct order. There's also some sample CSS to get people started. :)

    I have also successfully rebuilt the project to deploy to the GAC and offered instruction in a related thread.

    Thanks very much for a solid solution. I can't believe this was still missing from 2010!

  115. Saji Ijiyemi Says:

    @Waldek, I deployed ECQWP but my contents are only visible in Edit mode and could not figure out why my page is blank in view mode. Could you offer any advice? Thanks.

  116. Waldek Mastykarz Says:

    @Saji: Could it be that you didn't publish/approve the custom XSLT files?

  117. Saji Ijiyemi Says:

    @Waldek Thanks for your response. The XSLT files are published and approved. The "Hidden" is unchecked on the Layout section of the Content Query Tool Part (Modify Shared Web part).Any other thought. Really appreciate it. Thanks.

  118. Waldek Mastykarz Says:

    @Saji: Could you check if any of the out of the box styles displays anything? This might help you determine if there is issue with XSLT or the query.

  119. Saji Ijiyemi Says:

    @Waldek Thanks again. The Out of the Box (OOB) styles are displaying without any problem. I added the OOB CQWP and it displays everything fine. I also observed that the Title of the ECQWP is showing but not the content. Thanks again. I really appreciate your help.

  120. Waldek Mastykarz Says:

    @Saji: Could you try adding <textarea><xsl:copy -of select="."/></textarea> to the root template in ContentQueryMain.xsl to see what the XML response generated by the CQWP is?

  121. Saji Ijiyemi Says:

    @Waldek Thanks again. Pls, where exactly do I add ? The code is kind of intimidating. Heel bedankt. My wife is Dutch, so I know that. Thanks.

  122. Waldek Mastykarz Says:

    @Saji: Just add the code I mentioned right below in ContentQueryMain.xsl or your customized version of it.

  123. Saji Ijiyemi Says:

    @Waldek Thanks again. The code did not make nay difference. Do you want me to send you my codes in an email or I should post them. I will be grateful if you can take a look at them.

  124. Waldek Mastykarz Says:

    @Saji: Feel free to send me the code using the contact form, although I cannot promise when I will be able to have a look at it.
    When you're saying it didn't make any difference: you should be able to see a textarea with the CQWP XML output in it. If you don't it means that your CQWP doesn't use your XSL at all and there is little point of me having a look at it.
    One more thing that you might want to read is the MSDN article on customizing CQWP's XSL (http://msdn.microsoft.com/en-us/library/bb447557.aspx). It might contain some helpful tips.

  125. Saji Ijiyemi Says:

    @Waldek, Thanks for your efforts, really appreciate it.

    You are right that the ECQWP doesn't use the ContentQueryMain.xsl.

    The enhanced web part comes with its own ECQWPItems.xslt and ECQWPMain.xslt (I believe a customized version of the out of box ItemStyle.xsl and ContentQueryMain.xsl respectively).

    I also noticed that both the Out of the box CQWP and ECQWP are using the same Header.xsl and the out of box webpart is displaying correctly in 'View' and 'Edit' mode.

    I am wondering what role the ContentQueryMain.xsl plays in all this (if any). Thanks.

  126. Saji Ijiyemi Says:

    @Waldek, Here is the ItemStyle that comes with the Customized CQWP:

    _blank

    <![CDATA[

     

    Title

    Last Modified

    ]]>

    <![CDATA[]]>

  127. Saji Ijiyemi Says:

    @Waldek, The xml was truncated, it did not display properly ( as you can see above). Any other option to get the file across to you?

    Thanks.

  128. Saji Ijiyemi Says:

    @Waldek, I found you on msdn forum. have posted the code to the msdn forum at:
    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/b2a8ae26-45d1-401d-9518-7f2895670534/#1a9b1d66-2650-4b32-80af-35b80f6e018b

    Hope you will find time to look at it. Thanks.

  129. Saji Ijiyemi Says:

    @Waldek, I logged in to SharePoint as another user (other than an Admin) and discovered something even more strange:The web part was visible in 'View' and 'Edit' modes. However, instead of displaying normal files like .xls, .doc, .pdf, the files displayed are .xls, .jpg, and .css

    Hope that provides some insight into what might be going on.

    Thanks.

  130. Waldek Mastykarz Says:

    @Saji: because the ECQWP uses the customized XSL files you have to add the code I mentioned before to that file, instead the default ContentQueryMain.xsl. As you notiecd, it doesn't play any role whatsoever since the ECQWP uses a customized version of it.
    As for the extensions/file type: I don't really see how that would have impact on your issue.

  131. Saji Ijiyemi Says:

    @Waldek. after inserting below in the ECQWPMain.xslt

    I got:
    .
    I don't know what this implies but hope we are getting close to the solution. Thank you very much.

  132. Saji Ijiyemi Says:

    @Waldek. It's like this page is not accepting codes. You can see what I got after adding the code you suggested, here: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/b2a8ae26-45d1-401d-9518-7f2895670534/#1a9b1d66-2650-4b32-80af-35b80f6e018b

  133. Saji Ijiyemi Says:

    @Waldek, Thanks for continuing to help. I don't know how to set both the number of items per page and the page parameter value. This has been a great learning curve for me and I'm still learning. I will appreciate your help to do that. Thanks. http://tinyurl.com/2wk5ks8

  134. Saji Ijiyemi Says:

    @Waldek, Thanks for continuing to help. I don\'t know how to set both the number of items per page and the page parameter value. This has been a great learning curve for me and I\'m still learning. I will appreciate your help to do that. Thanks. http://tinyurl.com/2wk5ks8

  135. Rahul Says:

    Hi,

    I have a requirement in my Project, where i have to add a Dropdown list for displaying the number of results per page along with the Paging mechanism. Can you please let me know how we can achieve this.

  136. Waldek Mastykarz Says:

    @Rahul: At this moment the Extended CQWP doesn't support setting the page size dynamically. What you would need to do for that is to create your own extended version that would accept the page size through a query string parameter. Andrew Connell has a good article about extending the CQWP @ http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx.

  137. David McMillan Says:

    Hi Waldek,

    THanks for the great post, I have a co-worker who used your code in a site we are creating and everything has installed and appears to be working fine except for one strange occurance, I hope you can help with. When we deploy the ECQWP and the pager everything appears to render fine with the ECQWP displaying the correct number of items and the correct format from the XSLT and the pager renders with the correct number of pages. The problem occurs when a visitor logs into the page, everything renders fine, but when the user clicks on another page the page refreshes with the parameter ?page=2 or whatever page is clicked, but the ECQWP does not go to that page, but instead renders the first page again (which is seems to know it is on based on the nav). There are no errors when this happens and to further confuse matters, if you wait for a couple minutes and click again the page will refresh properly and then work from then on. We thought it might be something timing out, but can find no processes or error in the code. In addition, any users with elevated rights do not experience the issue. Have you seen or heard of anything like this? or do you have any insights that might help? Thanks again, your help is appreciated.

  138. Waldek Mastykarz Says:

    @David: Could it be that the page is being cached?

  139. David McMillan Says:

    That is what we have been leaning toward, the caching was not configured on the ECQWP so I eanbled it and set it to 30 seconds to see if that might make a difference, it didn't, so we are now exploring the possibility of the Site Output cache, which defaults to a 180 second cache. I was hoping you might have seen this before and could point us to what needed to be changed, I will post the cause once we have it.

  140. David McMillan Says:

    Hi Waldek,

    We think we found the solution, if you are using Site Collection Output caching, you will need to set the Vary by Query String Parameters to allow the pagination to work properly. This will need to be set to * for the profile that will be performing the actions. Thanks for everything, love the web part.

  141. David McMillan Says:

    Just a further note, the reason elevated rights did not see the issue is that in most page output caching profiles 'Allow writers to view cached content' is set to 'No'.

  142. Waldek Mastykarz Says:

    @David McMillan: Now you mention it, it totally makes sense! Thank you very much for going after it and posting back the solution, I really appreciate it! Great stuff!

  143. Jeff Rickard Says:

    Just following up on Dave's comment as I work with him. A blog entry about the solution is up on my blog over at http://blog.mandrakeindustries.com/2011/01/12/extended-content-query-pager-not-paging-properly/

  144. Waldek Mastykarz Says:

    @Jeff: Excellent! Thank you :D

  145. A little more about Content Query Web Parts | ankursharepoint Says:

    [...] http://blog.mastykarz.nl/paging-content-query-web-part/http://blog.mastykarz.nl/paging-content-query-web-part-how-i-did-it-part-1-inside-the-cqwp/ [...]

  146. Vaibhav Jain Says:

    Hi Waldek,

    Is there a way we can implement paging in CQWP using XSL? Just like we can introduce paging in Data view webpart or List view webpart using XSL.

    Thanx in advance.

    Vaibhav

  147. Waldek Mastykarz Says:

    @Vaibhav: Not that I know of.

  148. Joana Says:

    How about combining the two webparts, filtering and paging? I am trying to do this but i need some guidance…

  149. Waldek Mastykarz Says:

    @Joana: Paging takes place after retrieving the results so the only thing that you have to take care of is the filtering.

  150. Joana Says:

    Combining the two, i can filter the page but when i change the page to view more results the filter desappear…

  151. Joana Says:

    The problem seems to be in the link in the number of the page. Because the filter is made by querystring like ?Filter1Field=Name&FilterValue=joana, when we click in the page only appears ?page=2 and we need ?Filter1Field=Name&FilterValue=joana&page=2…Some suggestions?

  152. Joana Says:

    Can I add & to the xsl to add more than one parameter in querystring? Give me XSLT error.

  153. Waldek Mastykarz Says:

    @Joana: You should be able to do it by encoding the &.

  154. Blogempfehlung http://blog.mastykarz.nl - SharePointBlog Says:

    [...] Paging Content Query Web Part Paging Content Query Web Part – How I did it – Part 1: Inside the CQWP SharePoint 2010 Content Query Web Part with paging [...]

  155. Chris Says:

    Hi Waldek,
    I've deployed the wsp successfully and activated the webparts. I can also see the 2 webparts in the webpart gallery, but when I try to add either to the page I get:

    "An error occurred while attempting to add the item to the page".

    Where am I going wrong? I have Sharepoint 2010.

  156. Waldek Mastykarz Says:

    @Chris: hard to say without more detailed information. I suggest you either disable custom errors or take a look in ULS to get some more information.

  157. Chris Says:

    Hi Waldek,

    Looking through the error logs for:
    Correlation ID:a5bc6824-e077-4189-8e47-ee9da6bf1169

    The following seem to be relevant:

    Error while executing web part: System.Security.SecurityException: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed. at Microsoft.SharePoint.SPSite..ctor(Guid id, SPUrlZone zone, SPUserToken userToken) at Microsoft.SharePoint.Publishing.CachedObjectFactory.get_SuperUserSite() at Microsoft.SharePoint.Publishing.CachedArea.GetCrossListQueryResults(SPSiteDataQuery query, SPWeb currentContext, Boolean onlyPopulateCache, Boolean useSpQueryOnList, Int32 lcid) at Microsoft.SharePoint.Publishing.CrossListQueryCache.GetSiteDataResults(CachedArea cachedArea, SPWeb web, SPSiteDataQuery query, Boolean useSpQueryOnList) at Microsoft.SharePo… a5bc6824-e077-4189-8e47-ee9da6bf1169

    AND

    The action that failed was: Demand The type of the first permission that failed was: Microsoft.SharePoint.Security.SharePointPermission The Zone of the assembly that failed was: MyComputer a5bc6824-e077-4189-8e47-ee9da6bf1169

    I've changed the trust level to Medium in the following web.config files:
    C:\inetpub\wwwroot\wss\VirtualDirectories\80
    C:\inetpub\wwwroot\wss\VirtualDirectories\29359

    Any help would be much appreciated :)
    Chris

  158. Chris Says:

    Hi Waldek,
    I've resolved the issue. I was using the old 2 part web part. I've installed v14 instead and that works a treat! Excellent work :)

    One question though. I have the rss feed for the CQWP but this doesn't take into account the paging. is there a way to output the RSS of what is actually on the screen i.e. adhere to the paging.

    Thanks again
    Chris

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2012 Waldek Mastykarz

Creative Commons License