Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
482 views
in Q2A Core by

If we want to close a question there is an option:"this is similar to another question". And then I use Kai's override to mark that question as [duplicated].

I want there exists another option: "Closed as off-topic"and then mark it as [off-topic].

Thanks.

Q2A version: 1.6.3

1 Answer

+2 votes
by
selected by
 
Best answer

It is a dirty fix but should work:

function q_item_title($q_item) {
    $html = '';
    if(isset($q_item['raw']['closedbyid'])) {
        $result = qa_db_read_one_assoc(qa_db_query_sub(
            'SELECT content, type FROM ^posts WHERE postid = #',
            $q_item['raw']['closedbyid']
            ), true
        );
        if(isset($result)) {
            if ($result['type'] === 'NOTE') {
                $reason = 'Off-topic';
                $class = 'offtopic';
            } else {
                $reason = 'Duplicate';
                $class = 'duplicate';
            }
            $html = sprintf('<span class="qa-q-%s">[%s]</span>', $class, $reason);
        }
    }
    $this->output(
        '<div class="qa-q-item-title">',
        $html,
        sprintf('<a href="%s">%s</a>', $q_item['url'], $q_item['title']),
        '</div>'
    );
}
 
This will output Off-topic or Duplicate as the text and qa-q-duplicate and qa-q-offtopic as the CSS classes to use in each case.
by
Pupi1985: Thanks. But there is an error for me:Fatal error: Cannot redeclare qa_html_theme::q_item_title()...
by
That's because you are adding the code and you should replace the function that you've added previously.
by
you're Right! It works for me. Thank you very much.
...