Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

How to show comment numbers?

Hi does anyone know of a way to number the comments in a discussion? Presumably this would be through a plugin.

I'm on Vanilla 3.2.

Here's an example of a forum that has numbered comments:


That's an older version of vanilla, which is using a non-standard plugin called EnhancedComments: https://github.com/loopspace/EnhancedComment

But that plugin is not playing well with the theme I'm using (Keystone) on 3.2. Also it's doing other stuff besides numbering the comments which are garbling the presentation.

I could always try hacking on that plugin, but just wondering if the numbering issue has already been solved in a more mainstream way.

Thanks!

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    That's easy. You need a plugin which does not much more than this:


       public function discussionController_discussionInfo_handler($sender, $args) {
           echo '<span class="MItem CommentCounter">'.anchor(
               '#1',
               $sender->Discussion->Url,
               'Permalink',
               ['rel' => 'nofollow']
           ).'</span>';
       }
    
       public function discussionController_commentInfo_handler($sender, $args) {
           $permalink = $args['Comment']->Url ?? '/discussion/comment/'.$args['Comment']->CommentID.'/#Comment_'.$args['Comment']->CommentID;
           echo '<span class="MItem CommentCounter">'.anchor(
               '#'.strval($args['CurrentOffset'] + 1),
               $permalink,
               'Permalink',
               [
                   'name' => 'Item_'.$args['CurrentOffset'],
                   'rel' => 'nofollow'
               ]
           ).'</span>';
       }
    

    Additionally you can use some CSS that will re-order the number. I've put some quick proof of concept together. It should be pretty complete, but the css would need to be tested on different browsers.

    https://us.v-cdn.net/5018160/uploads/301/04ND30TAJCQU.zip There was an error displaying this embed.



    Bleistivt
  • Thanks R_J, that’s a great help!

Sign In or Register to comment.