@@ -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;
|
||||
|
||||
@@ -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 @@
|
||||
<nav class="pagination" role="navigation">
|
||||
@if (page > 1)
|
||||
{
|
||||
<a class="prev" href="?page=@(page - 1)">Prev</a>
|
||||
queryString["page"] = (page - 1).ToString();
|
||||
<a class="prev" href="?@queryString">Prev</a>
|
||||
<span>…</span>
|
||||
}
|
||||
|
||||
@for (var i = (page - 1 > 0 ? page - 1 : 1); i < (page + (pagesToShowLeft - (page - 1 > 0 ? 1 : 0))) && i <= pages; i++)
|
||||
{
|
||||
<a class="@Umbraco.If(i == page, "active")" href="?page=@i">@i</a>
|
||||
queryString["page"] = i.ToString();
|
||||
<a class="@Umbraco.If(i == page, "active")" href="?@queryString">@i</a>
|
||||
}
|
||||
|
||||
@if (page < (pages - 3))
|
||||
@if (page < pages)
|
||||
{
|
||||
queryString["page"] = (page + 1).ToString();
|
||||
<span>…</span>
|
||||
<a class="next" href="?page=@(page + 1)">Next</a>
|
||||
<a class="next" href="?@queryString">Next</a>
|
||||
}
|
||||
</nav>
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ FETCH NEXT @count ROWS ONLY";
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
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<int>(sql, new { category = category });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user