Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top