Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
852 views
in Q2A Core by
Is there a way to count comments on questions like the way it counts answers to questions?  It would be nice to be able for users to see that there is activity on a question even if there are no answers but there are comments.  Thanks.

1 Answer

+7 votes
by
selected by
 
Best answer

1. Create layer plugin.

1.1 Create "my-layer" folder under qa-plugin/.

1.2 Create plugin files under my-layer folder.

metadata.json​


"name": "My Layer", 
"description": "Custom layer", 
"version": "1.0", 
"date": "2017-04-19", 
"author": "PowerQA", 
"author_uri": "http://www.powerqa.org", 
"license": "GPLv2", 
"min_q2a": "1.5" 
}

qa-plugin.php​

<?php 
/* 
Question2Answer by Gideon Greenspan and contributors 
http://www.question2answer.org/
File: qa-plugin/my-layer/qa-plugin.php 
Description: Initiates My Layer plugin

This program is free software; you can redistribute it and/or 
modify it under the terms of the GNU General Public License 
as published by the Free Software Foundation; either version 2 
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php 
*/
/* 
Plugin Name: My Layer 
Plugin URI: 
Plugin Description: Custom layer 
Plugin Version: 1.0 
Plugin Date: 2017-04-19
Plugin Author: PowerQA 
Plugin Author URI: http://www.powerqa.org/ 
Plugin License: GPLv2 
Plugin Minimum Question2Answer Version: 1.5 
Plugin Update Check URI: 
*/

if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser 
header('Location: ../../'); 
exit; 
}
qa_register_plugin_layer('qa-my-layer.php', 'My Layer');

qa-my-layer.php​

<?php
/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/

File: qa-plugin/my-layer/qa-my-layer.php
Description: Event module class for my layer plugin

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

More about this license: http://www.question2answer.org/license.php
*/
class qa_html_theme_layer extends qa_html_theme_base {
    public function c_list($c_list, $class) {
        if (!empty($c_list) && count($c_list['cs'])) {
            $title = qa_lang_html_sub(count($c_list['cs'])==1 ? 'main/1_comment' : 'main/x_comments', count($c_list['cs']));
            $this->part_title(array('title' => $title, 'title_tags' => 'class="c_list_title"'));
        }
        qa_html_theme_base::c_list($c_list, $class);
    }
}

2. Add style

  1. Go to "Admin" > "Layout"
  2. Add style below into "Custom HTML in <head> section of every page"

<style>
.c_list_title {
padding: 5px 10px;
margin-bottom: -15px;
background: #ddd;
color: #333;
margin-top: 15px;
font-size: 14px;
}
</style>

Results

Note

This is a solution for question page. It is not question list.

by
Great, thanks for the help sama55.

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...