Imtech Extended ContentQueryWebPart (with paging) source code available

, , , ,

Some time ago I have created a concept of the ContentQueryWebPart extended with paging support, called Imtech Extended ContentQueryWebPart. Since its release, the Imtech ExCQWP has been downloaded more than 200 times and some of you have sent me some questions regarding how it all works.

One of the frequently asked questions was about sharing the source code of the web part. Because I'm curious of what other improvements could've been done, I have decided to post the source code and share it together with the .wsp.

The source code is available on CodePlex. Feel free to post any comments, suggestions and ideas of how the web part could be improved.

Possibly related posts

32 Responses to “Imtech Extended ContentQueryWebPart (with paging) source code available”

  1. mossbuddy Says:

    Hi Waldek, I saw your post here about the CQWP: http://blog.mastykarz.nl/imtech-extended-contentquerywebpart-with-paging-source-code-available/
    and thought if I can check with you on, how wld you achieve localization of the "custom web part properties" if the RESX file containing the localized strings are deployed to 12\Resources folders? Basically we are trying to avoid a satellite assembly for localization and keeping all our RESX entries in 12\Resources but not sure how to achieve the localization in this web part. Appreciate your valuable inputs.

  2. Waldek Mastykarz Says:

    It all depends where do you deploy the web part assembly. If it's GAC a satellite assembly is the only option I believe.

  3. MOSSBUDDY Says:

    Thanks Waldek, but I am not making the resx file part of the satellite file, actually the resx file will be deployed to 12\Resources folder and then using the SPUtility.GetlocalizedString() method I can get the localized value. I was not sure how would I use it with the Extended CQWP, as in webparts derived form Sharepoint.Webparts.WebPart we can use the loadResource() method and override the behavior by using SPUtility.GetLocalizedString().

  4. MOSSBUDDY Says:

    Also I had another query on, what if one of the field in the Pages library that I am querying in my ECQWP is a RICH TEXT Field (with Html tags). Will the query returned by the EQWP (as XML) have the html tags intact? Appreciate your consitent help to me.
    thank you.

  5. Waldek Mastykarz Says:

    @MOSSBUDY: As far as I know the HTML is being escaped by default. You can suppress is by including the disableoutputescaping="yes" attribute in xsl:value-of

  6. Waldek Mastykarz Says:

    @MOSSBUDY: I've seen some sample usage @ the MSDN page: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getlocalizedstring.aspx. Have you looked there?

  7. MOSSBUDDY Says:

    I did look at those samples already, just wanted to understand how we can use it in your implementation of ECQWP. After little digging I found I need to replace the STRINGS in the toolpart by the SPUtility.GetlocalizedString() and that should do it.
    Thanks a lot Waldek, you have been very humble and prompt and helpful. thanks again.

  8. MOSSBUDDY Says:

    Hey Waldek, as you have the Paging implementation, I thought I can check with you if you have tried the AJAX type implementation with the ECQWP? As currently it is a complete post back, once the user clicks on the Page number. With AJAX type implementation it would be only that part of the page that will be refereshed. Thought of checking with you, if you had tried.

    thanks.

  9. Waldek Mastykarz Says:

    @MOSSBUDY: That would improve the user experience indeed. On the other hand: I've developed the CQWP paging for WCM solutions in particular. In such scenario JavaScript is an optional technology on which you cannot rely. Second of all using the approach based on query string parameters you are able to persist the state: you can send someone a link to the 4th page. Using AJAX approach that wouldn't be possible as the URL doesn't change.

  10. MOSSBUDDY Says:

    Thats a real nice explanation and a very valid point on the query string parameter. Thank you Waldek.

  11. MOSSBUDDY Says:

    Hey Waldek, I wanted to request you for another suggestion/advice from you. Is there anyway to hide the ECQWP if the number of records returned by the Query is 0. We would not event like to display an empty chrome with just the web part title, basically that area would appear blank.
    thank you.

  12. Waldek Mastykarz Says:

    @MOSSBUDY: When it comes to output it shouldn't be that difficult. You would most likely have to modify the ContentQueryMain.xsl as it's the entrance point of the XSLT transformation applied to the XML results.
    As it comes to hiding the whole Web Part: I don't think it's doable in a manageable way. I mean, sure you could hack something together but is it really worth it? If it's really that important: why use the standard chrome? If you want to display the Web Part title you could extend the XSLT parameters and create your own title bar inside the XSLT which you could conditionally hide.

  13. NewInMOSS Says:

    Hi There,

    Thank you for your nice post.I just started working in MOSS.i don't know how to install the web part.can you please send some installation step so i can go ahead and install and play with it.

    Thank You

  14. Waldek Mastykarz Says:

    The Web Parts are provided in two forms: as SharePoint solution (WSP) and source code. To get the Web Part working on your site you have to first add the solution to your farm (stsadm -o addsolution), then deploy it to your Web Application using Central Administration > Operations > Solution Management and as last activate the Feature in your Site Collection using Site Actions > Site Settings > Site Collection Features. The Web Parts should become available and you should be able to put them on pages just as you would with any other Web Part.

  15. NewInMOSS Says:

    Thank You!!

  16. MOSSBUDDY Says:

    Hey Waldek, another quick question I have a List with CUSTOM FOLDER content type and CUSTOM ITEM content type. Folder acts as a Parent and Items inside the Folder content type are child to the Folder. Folder also has some attributes and this list purely mimicks Parent-Child information as available here: http://cisa.ca/blogs/medhat/archive/2007/10/30/simulate-parent-child-relationship-in-sharepoint-2007-with-folders-amp-content-types.aspx. Now I have to use your ECQWP to get a result that looks like as follows:

    Comp_ID:123(coming from Folder, this if Folder attrib)
    Comp_Name: ACME Corporation (coming from Folder, this if Folder attrib)

    Employee ID 111: Jane Doe Downtown (comes frm item)
    Employee ID 222: James White Apt (comes frm item)

    Company ID : 456
    Company Name : Bogus Enterprises
    Employee ID 333: Judy Black Main Street
    Employee ID 444: Brandon Wiley Riverside

    So is there a way to write a CAML query that would return the results as shown above (these 2 items are using different content types, although). Is it possible to do this within ECQWP?

    thanks

  17. Waldek Mastykarz Says:

    I don't think you would be able to get results in such way in a straight-forward manner. I mean you could always use XSLT to hack it around, but I'm not sure it will be easy, unless each item _knows_ in which folder it's being stored?

  18. mossbuddy Says:

    Thanks Waldek,
    Wish you Happy Christmas and Happy Holidays!

  19. Waldek Mastykarz Says:

    @mossbuddy: You're welcome! Same to you :)

  20. MOSSBUDDY Says:

    Hey Waldek, sorry to bother you again. Going back to the query of Parent-Child. If I store both the Parent element and Child element in the Pages Libaray (so no folder) but different content type, do you think I will be able to get the data and apply the XSL on that so that it looks like:

    Company ID : 456
    Company Name : Bogus Enterprises
    SOME MORE DATA ABOUT THE COMPANY kind of SUMMARY etc.

    Employee ID 333: Judy Black Main Street
    Employee ID 444: Brandon Wiley Riverside
    Employee ID 111: Hello Street
    Employee ID 222: Buffalo Riverside

  21. Waldek Mastykarz Says:

    @MOSSBUDY: There is no JOIN in CAML so you would have to find another way of retrieving the related items. Of course if you would get all the items you could achieve the grouped view just as you mentioned. You would retrieve the related nodes using XPath

  22. debab ramzi Says:

    Hi,

    I have just a problem with the pager web part which renders the page numbers vertically. how to get them horizontally?

  23. Waldek Mastykarz Says:

    @debab ramzi: you can use CSS to get it displayed horizontally instead of vertically.

  24. ravikumar.sanapala Says:

    hai Waldek Mastykarz

    i am ravi and am feel very happy after used ur Extended Content Query Web Part and Extended Content Query Web Part Pager. Both are working fine. But in Extended Content Query Web Part Pager shows page numbers in Vertically with bullet feilds. how can i change that numbers in Horizontally.

    Plz help me

    thanks and regaurds

    Ravikumar.sanapala

  25. Waldek Mastykarz Says:

    @ravi: you should use CSS to get the job done. The easiest way to do that is to use:

    li { display: inline; }

    Please note that it's only the beginning and there are still some styling left specific to your scenario to get the job done.

  26. chahine Says:

    Hello,

    I create a webpart that herite from the extended and I defined the filter programmatically and when I add my webpart in a page layout, I create a page from this page layout the filter is not applied, I must do modify the webpart and set ok because the filter is on.

    So if you can help me,

    Thanks

  27. Waldek Mastykarz Says:

    @chahine: how do you apply the filter? Could you post some code?

  28. chahine Says:

    hello,

    this is my code:

    {
    this.FilterField1 = "Country";
    this.FilterType1 = "string";
    this.FilterOperator1 = FilterFieldQueryOperator.Eq;
    if (myCondition)
    this.FilterValue1 = "canada";
    else
    this.FilterValue1 = "usa";
    this.Filter1ChainingOperator = FilterChainingOperator.Or;
    }

    Best regards.

  29. Waldek Mastykarz Says:

    @chahine: At what point are you applying that filter?

  30. chahine Says:

    I test it for the onLoad, Render, Prerender but always the same problem.

  31. Waldek Mastykarz Says:

    @chahine: Have you seen Andrew Connell's article on the subject (http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx). The article contains step-by-step explanation and a code sample.

  32. chahine Says:

    Hi,

    Some person post the same problem like me, and Andrew Connell\'s did not respond to them.

    So I think there\'s no solution for this moment.

    Thank you for your help.

Leave a Reply

Security Code:

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

Creative Commons License