adjust pagination so each page shows `postsPerPage` posts
This commit is contained in:
barisusakli
2016-11-21 13:49:36 +03:00
parent db14c29e41
commit b49af0a135
2 changed files with 6 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ topicsController.get = function (req, res, callback) {
settings = results.settings;
var postCount = parseInt(results.topic.postcount, 10);
pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
pageCount = Math.max(1, Math.ceil(postCount / settings.postsPerPage));
if (utils.isNumber(req.params.post_index) && (req.params.post_index < 1 || req.params.post_index > postCount)) {
return helpers.redirect(res, '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : ''));