How to Show comments in discussion page?

In default discussion page, it just show comments.

I want make it show comments count, can you tell me how to edit it?

For example, my discussion page have 10 comments, I want make it show 10 comments at content bottom.

Comments

  • edited September 2018

    I have edited applications/vanilla/views/discussion/index.php

    echo '<h2 class="CommentHeading">';
    echo sprintf(
                                pluralTranslate(
                                    val('CountAllComments', $category), '%s comment html',
                                    '%s comments html',
                                    t('%s Reply'),
                                    t('%s Reply')
                                ), bigPlural(val('CountAllComments', $category), '%s Reply'));
    

    echo '';

    Bottom is old code:

    echo '<h2 class="CommentHeading">'
        .$this->data('_CommentsHeader', t('Reply')).'</h2>';
    

    But it was not work.

  • I have edited applications/vanilla/views/discussion/index.php

        echo '<h2 class="CommentHeading">';
        echo sprintf(
                                    pluralTranslate(
                                        val('CountAllComments', $category), '%s comment html',
                                        '%s comments html',
                                        t('%s Reply'),
                                        t('%s Reply')
                                    ), bigPlural(val('CountAllComments', $category), '%s Reply'));
       echo '</h2>';
    

    Bottom is old code:

        echo '<h2 class="CommentHeading">'
            .$this->data('_CommentsHeader', t('Reply')).'</h2>';
    

    But it was not work.

  • @Pimochutokyo said:
    I have edited applications/vanilla/views/discussion/index.php

    1. Read about custom themes and how to override a view. Otherwise you will get into troubles one day.
    2. Avoid overriding themes by all means, use a plugin instead

    @Pimochutokyo said:
    But it was not work.

    And why should it? You were trying to use a variable ($category) that isn't even defined in that context and if I assume would have shown a completely wrong information if it had succeeded.

    $category, if defined, holds information about the category. You are looking for information of the discussion. So you must access the discussion.


    Create a custom plugin, copy the example and strip out anything you do not need, which is everything between the first open { and the last closing } of the example plugin.
    It is important that your copy is in a folder which has the same name as your plugin and use that as the "key" in the addon.json

    Add this inside the curly braces:

    public function discussionController_beforeCommentHeading_handler($sender, $args) {
        $commentCount =$sender->data('Discussion')->CountComments;
        echo '<h2>'.printf(Plural($commentCount, '%s comment', '%s comments'), $commentCount).'</h2>';
    }
    

    @Pimochutokyo said:
    Hello?

    Hello. Let me introduce myself: I'm a volunteer and I feel annoyed by impatience.

Sign In or Register to comment.