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

Hi,

I wrote some code in my plugin with which the Moderators can choose a "Question of the Week".

I now want to show it on the Home Page, as the 1st Entry in the "Recent Questions", with some Highlighting. I can do that by overriding the functions in the Class qa_html_theme_base in my Custom Layer. For this, I need to add my question the q_list array. But when I analyzed the content of the array, it has a number of parameters in it, for every question to be displayed. I tried the method suggested in this post:
http://www.question2answer.org/qa/8843/how-to-retrieve-a-single-question-from-the-database

But the infomation fetched is significantly less than what the elements q_list of  have. Can anyone explain it to me, what's the best way to add a question in a custom way on the Home Page?

1 Answer

+1 vote
by
Off the top of my head, I don't think adding it to q_list is the way to go; better to just add a div before the q_list; at the beginning of the q_list function, retrieve a single question from the database and output it as you want it to be displayed.

If you really want it in the q_list, this seems to work:

        function q_list($q_list)
        {
            
            $postid = <yourpostid>;
            
            require_once QA_INCLUDE_DIR.'qa-db-selects.php';
            global $qa_login_userid, $qa_cookieid, $qa_request;

            $post=qa_db_single_select(qa_db_full_post_selectspec(null,$postid));
            
            $usershtml=qa_userids_handles_html(qa_any_get_userids_handles(array($post)));

            $options=qa_post_html_defaults('Q');

            $post = qa_any_to_q_html_fields($post, $qa_login_userid, $qa_cookieid, $usershtml, null, $options);
            
            array_unshift($q_list['qs'], $post);

            qa_html_theme_base::q_list($q_list);
        }
...