How to filter managed meta data column using page query string?

Traitée How to filter managed meta data column using page query string?

  • lundi 6 septembre 2010 17:21
     
     

    I have two managed term sets as follows:

    Articles:Downloads

    Projects:Downloads

    I am trying to use a content query web part to filter a list based on the above manged meta data column. I want to filter out only "Articles:Downloads"

    Scenario 1:

    When I edit the web part and directly set the filter option with the managed meta data column to "Articles:Downloads" it works fine. When I export the web part, in the .webpart file, the "FilterValue1" property has a value "Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910".

    Scenario 2:

    I want the web part to get the filter information from query string [PageQueryString:pageType]. So I tried using these options:

    a) pageType=Downloads 

        This works but returns downloads under 'projects' as well. (i want downloads only under 'articles') 

    b) pageType=Articles:Downloads

        Does not work and shows no records

    c) pageType = Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910

        Does not work. (This value is the same as one found in 'FilterValue1' of the static web part).

    c) pageType = Articles:Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910

        Does not work.

    d) pageType = 9096e43b-555d-4879-9acc-b4ada9ea9910

        Does not work.

     

    What am I missing here? Can some one please help?

Toutes les réponses

  • mercredi 8 septembre 2010 08:51
     
     Traitée

    HI karthik,

     

    Thanks for your post.

     

    I don’t think it’s possible to achieve this using “PageQueryString”. I think a work around about this is to change the managed term sets.

    For example:

    Before:

    Articles:Downloads

    Projects:Downloads

     

    After:

    Articles: ArticlesDownloads

    Projects: ProjectsDownloads

     

    Hope it’s helpful.

  • mercredi 8 septembre 2010 15:51
     
     

    Thank you very much  for the reply.

    However renaming the term sets is not an option for me, as the taxonomy structure is quite complex, already implemented and most of the other functionalities in my site heavily depend on the existing structure.

    I will try to sub class the content query web part and use the "query override" property to construct a dynamic CAML to solve my purpose.

    If there is a better way around this, please let me know.

     

  • jeudi 9 septembre 2010 08:30
     
     Traitée

    In case anyone else have the same problem, I solved this in the following way:

    1) Instead of passing the taxonomy path in the query string, I passed the WSSID of the taxonomy item.

    2) Created a custom web part that inherits from the content query web part.

    3) Set the QueryOverride property of the web part with my CAML generated dynamically (like below)

    <Where><Eq><FieldRef Name='{column name goes here}' LookupId='TRUE' /><Value Type='Integer'>{WSSID from querystring goes here}</Value></Eq></Where>

    4) Added this web part to the page and problem solved!.

    Thanks to:  http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx that helped me get rid of edit mode web part error, when setting the query override property.