HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Reverse Comment Sorting

Hi,

I've installed Vanilla Forum for first time, I have the latest version and I'm trying to reverse the comments order to sort ascending..

From default this is setted to desc, why?

Where I go to reverse the sorting? I've tryied from Admin Panel, from themes php files, discussion.php (in applications/vanilla), but I haven't found a solution..!

How to solve?

Tagged:

Comments

  • KasparKaspar ✭✭✭

    Try

    However it is old so may not work with latest VF version.

  • edited March 2020

    Hi..

    Thank you but I know this plugin and is the reverse that I want..!

    I want first the old comments.


    I've try to edit this plugin but not work.. This take the textbox first of comments..!

  • Solved by editing the plugin.

    Thank you

  • KasparKaspar ✭✭✭

    Sorry, if I misunderstood.


    Comments are listed with oldest ones first and newer underneath by default.

    So you should not need a plugin for that.



    In conf/config-defaults.php under embedding forum & comments you can find this

    $Configuration['Garden']['Embed']['SortComments'] = 'desc';

    Add it to your conf/config.php

    Changing desc to asc I assume would do it.

  • Thanks for lesson 😂🖤

  • prdvprdv New
    edited April 2022

    In my case, I want to list the embedded comments in a "newest first" order but... they appear to be unordered when there are "more comments" underneath

    Info: the ordering doesn't work when the comments are embedded

  • Auto answer:

    In applications/vanilla/models/class.commentmodel.php

    This code:

      359       $sql2->select('CommentID')
      360         ->from('Comment c')
      361         ->where($where, null, true, false)
      362         ->limit($limit, $offset);
      363       $this->orderBy($sql2);
      364       $select = $sql2->getSelect();
      365
      366       $px = $this->SQL->Database->DatabasePrefix;
      367       $this->SQL->Database->DatabasePrefix = '';
      368
      369       $this->SQL->join("($select) c2", "c.CommentID = c2.CommentID");
      370       $this->SQL->Database->DatabasePrefix = $px;
      371     }
    

    should be like this:

      359       $sql2->select('CommentID')
      360         ->from('Comment c')
      361         ->where($where, null, true, false)
      362         ->limit($limit, $offset);
      363       $this->orderBy($sql2);
      364       $select = $sql2->getSelect();
      365
      366       $px = $this->SQL->Database->DatabasePrefix;
      367       $this->SQL->Database->DatabasePrefix = '';
      368
      369       $this->SQL->join("($select) c2", "c.CommentID = c2.CommentID");
    +           $this->orderBy($this->SQL);
      370       $this->SQL->Database->DatabasePrefix = $px;
      371     }
    


Sign In or Register to comment.