Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
553 views
in Plugins by

I would like to add number of answers or up votes given to

 each related question items like this picture:

But don't know how to do that:)

Q2A theme: SnowFlat

 

                                                                                                     

 

 

Q2A version: 1.7.1
by
This is an awesome add.  Brings it inline with StackExchange.  I don't want to view related topics that have zero/low answers.

1 Answer

+1 vote
by
selected by
 
Best answer

I think I have done it. I share the code and hope developres tell me if it is true or not since this is my first code :)

 

 

class qa_related_qs
{
    .

   .

   .

        

        $minscore = qa_match_to_min_score(qa_opt('match_related_qs'));

        foreach ($questions as $key => $question) {
            if ($question['score'] < $minscore)
                unset($questions[$key]);
        }

        $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title');
       
$x=array();
        foreach ($questions as $question) {
            array_push($x, $question['acount']);
        }

        if ($region == 'side') {
            $themeobject->output(
                '<div class="qa-related-qs">',
                '<h2 style="margin-top:0; padding-top:0;">',
                $titlehtml,
                '</h2>'
            );

            $themeobject->output('<ul class="qa-related-q-list">');
           
for($i=max($x); $i>-1; $i=$i-1){
                foreach ($questions as $question) {
                    if($question['acount']==$i){
                    $themeobject->output(
                        '<li class="qa-related-q-item">' .
                        '<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' .
                        '<span style="background-color:lightgrey;">'.'&nbsp '.qa_html($question['acount']).'&nbsp '.'</span>'.' '.qa_html($question['title']).
                        '</a>' .
                        '</li>'
                    );
                    }
            }
            }

            $themeobject->output(
                '</ul>',
                '</div>'
            );
        } else {
            $themeobject->output(
                '<h2>',
                $titlehtml,
                '</h2>'
            );

            .

            .

            .

        }
    }
}

...