Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.0k views
in Plugins by
edited by

My goal was to remove all best answer outputs from the question page.

On layer level (not overrides) I have tried to remove the best answer.

These attempts were not successful:

        public function a_list_items($a_items)
        {
            foreach ($a_items as $a_item) {
                $a_item['raw']['isselected'] = false;
                $a_item['selected'] = false;
                $this->a_list_item($a_item);
            }
        }


Then I saw that format.php adds the css class (!) as an extra field:

     $fields['classes'].=' hentry '.($isquestion ? 'question' : ($isanswer ? ($isselected ? 'answer answer-selected' : 'answer') : 'comment'));


So the only chance (again: not using core function overrides) to remove the selected best answer, is to remove the css class from $a_item['classes']:

        public function a_list_items($a_items)
        {
            foreach ($a_items as $a_item) {
                $a_item['classes'] = str_replace(' answer-selected', '', $a_item['classes']);
                    if(isset($a_item['select_text'])) {
                        unset($a_item['select_text']);
                    }


                $this->a_list_item($a_item);
            }
        }
 

I am not sure... in my special case I think the current q2a core way is not the best implementation. What do you think?

Q2A version: 1.7

1 Answer

+3 votes
by

I took a look at this and I agree with you in the solution you've found.

This issue happens because the core is sending the theme (which is responsible of creating the CSS and HTML code) the CSS and HTML themselves. I complained about that in http://www.question2answer.org/qa/31514/what-do-you-want-in-question2answer-1-7?show=31529#a31529 . There are many places in the core in which this happens and it definitely shouldn't.

by
Thanks again for your feedback :)

I +1ed the "avoid the output of HTML from the core"
by
+1 for the "avoid the output of HTML from the core"  .
Because it causes so many issues/confusions while creating few elements for the advanced themes .
...