mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
closes #3720
This commit is contained in:
@@ -81,7 +81,7 @@ categoriesController.list = function(req, res, next) {
|
||||
|
||||
categoriesController.get = function(req, res, callback) {
|
||||
var cid = req.params.category_id,
|
||||
page = parseInt(req.query.page, 10) || 1,
|
||||
currentPage = parseInt(req.query.page, 10) || 1,
|
||||
pageCount = 1,
|
||||
userPrivileges;
|
||||
|
||||
@@ -127,7 +127,7 @@ categoriesController.get = function(req, res, callback) {
|
||||
return helpers.redirect(res, '/category/' + cid + '/' + req.params.slug + (topicIndex > topicCount ? '/' + topicCount : ''));
|
||||
}
|
||||
|
||||
if (settings.usePagination && (page < 1 || page > pageCount)) {
|
||||
if (settings.usePagination && (currentPage < 1 || currentPage > pageCount)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ categoriesController.get = function(req, res, callback) {
|
||||
topicIndex = Math.max(topicIndex - (settings.topicsPerPage - 1), 0);
|
||||
} else if (!req.query.page) {
|
||||
var index = Math.max(parseInt((topicIndex || 0), 10), 0);
|
||||
page = Math.ceil((index + 1) / settings.topicsPerPage);
|
||||
currentPage = Math.ceil((index + 1) / settings.topicsPerPage);
|
||||
topicIndex = 0;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ categoriesController.get = function(req, res, callback) {
|
||||
set = 'cid:' + cid + ':tids:posts';
|
||||
}
|
||||
|
||||
var start = (page - 1) * settings.topicsPerPage + topicIndex,
|
||||
var start = (currentPage - 1) * settings.topicsPerPage + topicIndex,
|
||||
stop = start + settings.topicsPerPage - 1;
|
||||
|
||||
next(null, {
|
||||
@@ -249,12 +249,10 @@ categoriesController.get = function(req, res, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
data.currentPage = page;
|
||||
data.pageCount = pageCount;
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
data.rssFeedUrl = nconf.get('relative_path') + '/category/' + data.cid + '.rss';
|
||||
data.title = data.name;
|
||||
data.pagination = pagination.create(data.currentPage, data.pageCount);
|
||||
data.pagination = pagination.create(currentPage, pageCount);
|
||||
data.pagination.rel.forEach(function(rel) {
|
||||
rel.href = nconf.get('url') + '/category/' + data.slug + rel.href;
|
||||
res.locals.linkTags.push(rel);
|
||||
|
||||
Reference in New Issue
Block a user