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

There are so many reply links, but all do the same, they open the same editor window.

I saw that stackoverflow is providing only one reply link after each comment thread. 

Wouldn't this be better?

Q2A version: 1.7.1

1 Answer

+1 vote
by
edited by

I could find a way how to do it like described above:

1. disable admin option

In admin/viewing/ → uncheck "Show reply button on comments" (or use CSS to hide them)
 

2. in qa-theme.php you would need:

        public function c_list($c_list, $class)
        {
            qa_html_theme_base::c_list($c_list, $class);
            if (!empty($c_list['cs'])) {
                // get first element of comment list array
                // $firstcomment = reset($c_list['cs']);
                // memo: dont take first as this could be the expand tag array (if comments get hidden within "show x comments before")
                
                // get last element of comment list array
                $lastcomment = end($c_list['cs']);
                
                $parenttype = qa_db_read_one_value( qa_db_query_sub( 'SELECT `type` FROM ^posts
                                WHERE `postid` = #', $lastcomment['raw']['parentid']), true );

                if(isset($parenttype)) {
                    $parenttype = strtolower($parenttype);
                    // default question
                    $namelink = 'q_docomment';
                    if($parenttype=='a') {
                        $namelink = 'a'.$lastcomment['raw']['parentid'].'_docomment';
                    }
                    $this->output('
                        <input name="'.$namelink.'" onclick="return qa_toggle_element(\'c'.$lastcomment['raw']['parentid'].'\')" value="'.qa_lang_html('question/reply_button').'" title="'.qa_lang_html('question/reply_c_popup').'" type="submit" class="qa-form-light-button qa-form-light-button-comment qa-form-light-button-comment-last">
                    ');
                }
            }
        }

3. Add CSS your to qa-styles.css file.

    .qa-c-item-buttons .qa-form-light-button-comment {
        display:none;
    }
    .qa-form-light-button-comment-last {
        float:right;
        margin-top:10px;
        padding-bottom:10px;
        color:#07C;
        font-size:12px;
    }
    .qa-form-light-button-comment-last:hover {
        color:#1075DF;
    }

 

This leads to:

Unfortunately, this needs one more query per comment list... as I cannot get the basetype from $c_list.

by
@Scott: It would be helpful to output "parenttype" in ['raw']. Is that possible? Or maybe you see another way to avoid the additional query.
by
I had to update my code above since there are sometimes "hidden comments" (where it states "show x more comments"). That's why I needed to take the last array element from the $cs_list to be sure to read in a comment, and to get the correct parentid.
...