Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+9 votes
1.3k views
in Q2A Core by
Hello!

Is there a way I can synchronize the newest questions and show them on my website's frontpage? Let's say I have a website with a blog, Q2A, forums and so on and I am showing the newest of all of these mediums on my frontpage.

Could anyone post the code how to GET the newest questions from the database and show them in the following format:

<This is the question.>
<This is the date of the question e.g. 31. March 2010>
<These are the first 10-15 words from the question.>

Not more not less. And the question should link to the q2a question. Oh, and is it somehow possible to link it to the question without the #id of the latest answer? I find this quiet annoying and would like to turn it off.

That would be awesome! Thanks in advance.
by
anyway you could make an example of this?

2 Answers

+1 vote
by
Good question! The long-term solution to this is RSS shown within an iframe, but obviously that doesn't help you right now.

At this point I think your best bet might be to access the database directly, and then format the output as you like. You could connect to your Q2A MySQL database, then run a query like this:

SELECT postid, title, content, created FROM qa_posts WHERE type='Q' ORDER BY created DESC LIMIT 50

Then pull out the results using mysql_fetch_assoc() and format them however you like. You can use the postid to build the link - don't worry about including the question title in the URL - it will still work without it.

You might also find it helpful to get the dates in a format which is compatible with the PHP date() function - in that case, replace created in the query above with UNIX_TIMESTAMP(created).

Finally, don't forget to escape the title and content with htmlspecialchars(), to prevent any mishaps on your front page!
by
If someone makes this working I would be very interested in adding it to my site as well. It is a very good feature to attract visitors !!!

Excellent question !
by
The RSS is useful, but Integrated-SSI-Addon feels necessary for interoperability or fusion between the system.
Reference1: http://www.question2answer.org/qa/1236/is-there-the-person-developing-ssi (Answer[hint] of john is usefull!)
Reference2: http://www.simplemachines.org/community/ssi_examples.php
0 votes
by
The links to questions work fine if you remove the #id from the end of the link. It just goes direct to the question itself and not to the specific answer.
...