Is there a way to get topicPostSort always to oldest_to_newest as default on topic load?

Plugin Development
  • topicPostSort get saved in user profile settings, right. When you update the topic post sorting on any topic, all topics you open after that will load with that topicPostSort setting.

    I want to always load the topicPostSort to oldest_to_newest, and still give the user the ability to change that to newest_to_oldest, or other, but, when that user reloads the topic, or goes to another topic, I want the topicPostSort back to oldest_to_newest.

    Its like I want it to default to oldest_to_newest, and never save this setting in the user settings.

    I've tryied to use the filter:user.getSettings and the filter:user.saveSettings , and force the topicPostSort field to always be oldest_to_newest, but then the sorting select feature on the topic page doesnt work properly, is like all the options there always sort oldest_to_newest

  • You can make this work with making a smalll modification to core here Change that line to
    if (app.user.uid && false) {
    This will prevent saving the sort into user settings so it will also use ?sort query string.

    To fix the default sorting, you can use filter:user.getSettings and force topicPostSort to oldest_to_newest. Query param overrides user setting so if the user changes it from the dropdown ?sort=value will be used and the user setting will be ignored.

  • So in order to make it work, I need to do those 2 things, edit core, and filter:user.getSettings , right? or is it on or the other?

  • You need both.

  • It worked like a charm. Thanks.

    Do you think this update on the sort.js can be added in the core and maybe control the false statement with a config / setting variable from config.json or admin panel?

  • Please open an issue on our github tracker, I am not sure if we should just remove the saving to user settings in the sort dropdown all together and move the sort settings to /user/<slug>/settings like everything else. Then you can change the sort order in every topic without effecting your settings. The setting used in the user page would be the default sort when you enter a topic.

Suggested Topics