I have two Q2A installations on the same database.
The default posts are stored in qa_posts table.
The second installation posts are stored in new_posts table.
Is there a way to display a list of recent new_posts questions as a widget on the main Q2A site?
Currently I'm using feed tricks, but are there some "native" ways to do so?
The problem with ['q_list']['qs'] approach or qa_any_to_q_html_fields () function is that it may return the WRONG question urls due to the mismatch between the second table and the core variables.
So, my solution is to mimic how that function list questions.
Here's my solution and it is used in a widget. You can customize your own way, for example like add pagination or add author names, shorten post content strings, etc...
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $PostArray = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, content, created FROM `new_posts` WHERE `type`="Q" ORDER BY created DESC LIMIT 20 ') ); foreach($PostArray as $post) { $link = 'https://mywebsite.com/secondinstallation'.str_replace(".","",qa_q_path($post['postid'],$post['title'],false)); echo '<div class="qa-q-list-item"><h1><a href="'.$link.'">'.$post['title'].'</a></h1>'; echo '<p>'.$post['content'].'</p>'; echo '<span>Posted on '.$post['created'].'</span></div>'; } }
Welcome to the Q&A site for Question2Answer.
If you have a question about Q2A, please ask here, in English.
To report a bug, please create a new issue on Github or ask a question here with the bug tag.
If you just want to try Q2A, please use the demo site.