diff --git a/OurUmbraco.Client/src/js/search.js b/OurUmbraco.Client/src/js/search.js index 7b364901..84cd2bba 100644 --- a/OurUmbraco.Client/src/js/search.js +++ b/OurUmbraco.Client/src/js/search.js @@ -365,7 +365,8 @@ $('#search-options input[type=checkbox]').click(function () { newUri = updateQueryString("order", orderValue, window.location.href); } } else { - newUri = updateQueryString(this.name, this.checked, window.location.href); + newUri = updateQueryString(this.name, this.checked, window.location.href); + newUri = updateQueryString("page", 1, newUri); } console.log(newUri); window.location = newUri; diff --git a/OurUmbraco.Site/Views/Partials/Forum/Forum.cshtml b/OurUmbraco.Site/Views/Partials/Forum/Forum.cshtml index 3b73f808..42e903af 100644 --- a/OurUmbraco.Site/Views/Partials/Forum/Forum.cshtml +++ b/OurUmbraco.Site/Views/Partials/Forum/Forum.cshtml @@ -5,6 +5,9 @@ @inherits OurUmbraco.Our.Models.OurUmbracoTemplatePage @{ + // Save query string for use in pagination links + var queryString = HttpUtility.ParseQueryString(Request.QueryString.ToString()); + const int pagesToShowLeft = 4; int page; if (!int.TryParse(Request["page"], out page)) @@ -40,9 +43,9 @@ TimeSpan.FromSeconds(4)); } - var totalCountKey = "OurForumForumThreadCount[" + cat + "]"; + var totalCountKey = "OurForumForumThreadCount[" + cat + unsolved + noreplies + "]"; var totalTopics = (int)cache.GetCacheItem(totalCountKey, - () => topicService.GetAllTopicsCount(cat), + () => topicService.GetAllTopicsCount(cat, unsolved, noreplies), TimeSpan.FromMinutes(1)); var pages = (totalTopics / pageSize) + 1; @@ -168,19 +171,22 @@ diff --git a/OurUmbraco/Forum/Services/TopicService.cs b/OurUmbraco/Forum/Services/TopicService.cs index 4b23fad7..ac3a8fe3 100644 --- a/OurUmbraco/Forum/Services/TopicService.cs +++ b/OurUmbraco/Forum/Services/TopicService.cs @@ -123,7 +123,7 @@ FETCH NEXT @count ROWS ONLY"; /// /// /// - public int GetAllTopicsCount(int category = -1) + public int GetAllTopicsCount(int category = -1, bool unsolved = false, bool noreplies = false) { const string sql1 = @"SELECT COUNT(*) as forumTopicCount FROM forumTopics @@ -135,6 +135,18 @@ LEFT OUTER JOIN umbracoNode u2 ON (forumTopics.memberId = u2.id AND u2.nodeObjec var sql = (category > 0 ? sqlic : sqlix); + if (unsolved) + if (sql.Contains("WHERE")) + sql = sql + " AND answer = 0"; + else + sql = sql + " WHERE answer = 0"; + + if (noreplies) + if (sql.Contains("WHERE")) + sql = sql + " AND replies = 0"; + else + sql = sql + " WHERE replies = 0"; + return _databaseContext.Database.ExecuteScalar(sql, new { category = category }); }