Show latest post from specific forum

MikaelSoder

New member
Hi. I just recently got started on using xenforo and so far i really like it.

So i'm working on a forum and i've created a front page. On this page i would like to show the latest post from a specific sub-forum. What would you think would be the easiest way to accomplish this? So far i've tried to include the post template but i'm not really sure if it's how it's intended to be used. There's seems to be a lot of variables thats needs to be set.

I've also tried to make a simple SQL-query in a php-method which i call using php callback from my front page. A.t.m. i only return the post message as a string and i'm not really sure how i would proceed if i want to show the user info such as avatars and nicknames on the front page along with the message.

Any help is highly appreciated!
 
You should use XF to fetch any data. XenForo follows the MVC (model-view-controller) pattern. Models interact with the database, so you use models to fetch data.

In this case, you could use the getThreads function in XenForo_Model_Thread to fetch threads on certain conditions (in your case, in a certain node and ordered by the latest post, limited to however many results you want). You can then display this thread however you want.

As for displaying this data, you can look at existing XenForo templates (like message and post) to look at how XenForo displays this data. The template code is reusable to an extent and you can import the same CSS classes if you like, or you can design your own.
 
Top Bottom