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

If I have the option "Show answer form immediately" ticked it shows the answer form at the top of the page, whereas in 1.4 it showed underneath the answers. I find that's better because users should clearly read through the existing answers before adding their own.

The only way I've found to change this is in the core (as in the related question). Any theme method? Could it be moved in the next version (or an option to do this)?

Q2A version: 1.5-beta1

1 Answer

+2 votes
by
It's funny how easy this actually is... I must be spending too much time with this code :)

        function doctype()
        {
            qa_html_theme_base::doctype();
            if(isset($this->content['a_form'])) {
                $a_form = $this->content['a_form'];
                unset($this->content['a_form']);
                $this->content['a_form'] = $a_form;
            }
        }

All this does is send a_form to the end of the array, which causes it to show last.  There may be something it has to come before, but you can just unset and readd that as well, in the same way.
by
Ah, excellent... I figured it was a result of it being added to the array too early, but didn't realize it was so easy to move an element to the end of an associative array. Thanks, man!
EDIT: note, extra ) needed after the if clause :)
by
yw :) sorry, there was a typo, fixed now.
by
Where is that function located?
Should I add it manually? If so, to which file?
by
@JustAnna93rdk that function is part of the theme, so you'd need to edit the qa-theme.php file for your chosen theme.
Alternatively you could edit qa-theme-base.php but that won't survive upgrades.
by
Done! Thanks a million! :)
by
if you have two codes for different hooks how to merge these to work
function doctype()
        {
            qa_html_theme_base::doctype();
            if(isset($this->content['a_form'])) {
                $a_form = $this->content['a_form'];
                unset($this->content['a_form']);
                $this->content['a_form'] = $a_form;
            }
        }
...