Added ACP option to customise recent post

Before, could either be OP or last reply.

Now, you can choose between OP, last reply, or last post (which
includes OP)
v1.18.x
Julian Lam 9 years ago
parent 14df793ba6
commit 8eaff1492a

@ -31,7 +31,7 @@
"profileImageDimension": 128, "profileImageDimension": 128,
"requireEmailConfirmation": 0, "requireEmailConfirmation": 0,
"allowProfileImageUploads": 1, "allowProfileImageUploads": 1,
"teaserPost": "last", "teaserPost": "last-reply",
"allowPrivateGroups": 1, "allowPrivateGroups": 1,
"unreadCutoff": 2, "unreadCutoff": 2,
"bookmarkThreshold": 5 "bookmarkThreshold": 5

@ -105,14 +105,7 @@ module.exports = function(Categories) {
function (next) { function (next) {
topics.getTopicsFields(tids, ['tid', 'mainPid', 'slug', 'title', 'teaserPid', 'cid', 'postcount'], next); topics.getTopicsFields(tids, ['tid', 'mainPid', 'slug', 'title', 'teaserPid', 'cid', 'postcount'], next);
}, },
function (_topicData, next) { async.apply(topics.getTeasers, topicData),
topicData = _topicData;
topicData.forEach(function(topic) {
topic.teaserPid = topic.teaserPid || topic.mainPid;
});
topics.getTeasers(topicData, next);
},
function (teasers, next) { function (teasers, next) {
teasers.forEach(function(teaser, index) { teasers.forEach(function(teaser, index) {
if (teaser) { if (teaser) {

@ -26,7 +26,24 @@ module.exports = function(Topics) {
topics.forEach(function(topic) { topics.forEach(function(topic) {
counts.push(topic && (parseInt(topic.postcount, 10) || 0)); counts.push(topic && (parseInt(topic.postcount, 10) || 0));
if (topic) { if (topic) {
teaserPids.push(meta.config.teaserPost === 'first' ? topic.mainPid : topic.teaserPid); if (topic.teaserPid === 'null') {
delete topic.teaserPid;
}
switch(meta.config.teaserPost) {
case 'first':
teaserPids.push(topic.mainPid);
break;
case 'last-post':
teaserPids.push(topic.teaserPid || topic.mainPid);
break;
case 'last-reply': // intentional fall-through
default:
teaserPids.push(topic.teaserPid);
break;
}
} }
}); });
@ -113,7 +130,11 @@ module.exports = function(Topics) {
} }
pid = pid || null; pid = pid || null;
if (pid) {
Topics.setTopicField(tid, 'teaserPid', pid, callback); Topics.setTopicField(tid, 'teaserPid', pid, callback);
} else {
Topics.deleteTopicField(tid, 'teaserPid', callback);
}
}); });
}; };
}; };

@ -83,7 +83,8 @@
<div class="form-group"> <div class="form-group">
<label>Teaser Post</label> <label>Teaser Post</label>
<select class="form-control" data-field="teaserPost"> <select class="form-control" data-field="teaserPost">
<option value="last">Last</option> <option value="last-post">Last &ndash; Show the latest post, including the original post, if no replies</option>
<option value="last-reply">Last &ndash; Show the latest reply, or a "No replies" placeholder if no replies</option>
<option value="first">First</option> <option value="first">First</option>
</select> </select>
</div> </div>

Loading…
Cancel
Save