2

I am able to filter the CQWP Results using the query string by using the keyword (PageQueryString) (reference: http://blogs.msdn.com/b/ecm/archive/2010/05/14/what-s-new-with-the-content-query-web-part.aspx ) Is there a similar way to filter the results using value from a cookie?

1

I think you should use the idea from this awesome Andrew Connel's article:

http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx

All you need to do actually, is to replace Request.QueryString to Request.Cookies.

  • 1
    Be aware though that CQWP has changed since SP2007 – Anders Rask May 3 '11 at 19:25
1

You'll probably be able to do this, but you can't do it in the CQWP itself. The XSL in the CQWP runs server side, and the cookie is going to live client side. You can instead use script (I'd recommend jQuery) to read the cookie and further filter what the CQWP has sent to the browser.

Alternatively, you could use client side script entirely with either the Client OM or SPServices.

0

You can get the information from a cookie. Here is what I did.

    private string GetCookieInfo(string cookieName)
    {
        string cookieInformation = null;
        if (HttpContext.Current.Request.Cookies[cookieName] != null)
        {
            cookieInformation = HttpContext.Current.Request.Cookies[cookieName].Value;
        }
        return cookieInformation;
    }

I use the value returned in the cookie in CAML query to get information from a SharePoint list. The list information returned includes a value for the web URL, which is used by the CQWP to know what data to display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.