How to Fix The Problem of Content Search Web Part Query Template (Query Text) For Anonymous Users & Control Display Template with Pagination?

I'm using the following solution to change QueryTemplate on run-time:

http://blogs.msdn.com/b/davidrei/archive/2012/12/27/sharepoint-2013-set-content-search-web-part-querytext-attribute-programmatically.aspx

protected override void OnLoad(EventArgs e)
{
    if (this.AppManager != null)
    {
        if (this.AppManager.QueryGroups.ContainsKey(this.QueryGroupName) &&
            this.AppManager.QueryGroups[this.QueryGroupName].DataProvider != null)
        {
            this.AppManager.QueryGroups[this.QueryGroupName].DataProvider.BeforeSerializeToClient +=
                new BeforeSerializeToClientEventHandler(EnhanceQuery);
        }
    }
 
    base.OnLoad(e);
}
 
private void EnhanceQuery(object sender, BeforeSerializeToClientEventArgs e)
{
    DataProviderScriptWebPart dataProvider = sender as DataProviderScriptWebPart;
    string currentQueryText = dataProvider.QueryTemplate;
    string token = "{LANGUAGE}";
    if (currentQueryText.Contains(token))
    {
        dataProvider.QueryTemplate = currentQueryText.Replace(token, GetCurrentLanguage());
    }
}

However, the problem is about the control display template with pagination AND the anonymous access.

For anonymous users, once the page loads, the programmatic ally additional query is performed correctly, but while clicking on "Next" button, the additional query is being ignored.

How to fix this problem?

August 19th, 2015 3:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics