Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
1  
Be aware though that CQWP has changed since SP2007 –  Anders Rask May 3 '11 at 19:25

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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