<?php
$forumUrl = '/forum/'; //Forum URL, must end with slash
$limit = 10; // Display this number of last posts
$forumDirectory = realpath(__DIR__.'/../'); // Full path to forum folder
if(!$forumDirectory) {
die('$forumDirectory is incorrect!');
}
$startTime = microtime(true);
require($forumDirectory. '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($forumDirectory . '/library');
// Initializing application
XenForo_Application::initialize($forumDirectory . '/library', $forumDirectory);
XenForo_Application::set('page_start_time', $startTime);
// Loading dependencies
$xfDependencies = new XenForo_Dependencies_Public();
$xfDependencies->preLoadData();
// Initializing session
XenForo_Session::startPublicSession();
// Reading viewable nodes list
$nodeModel = XenForo_Model::create('XenForo_Model_Node');
$viewableNodes = $nodeModel->getViewableNodeList();
$nodeIds = array_keys($viewableNodes);
$nodeIdsList = implode($nodeIds, ',');
// Requesting last N viewable nodes
$sql_forum = "SELECT `title`, `thread_id`, `view_count`, `reply_count` FROM `xf_thread` WHERE `node_id` IN ($nodeIdsList) AND discussion_state='visible' ORDER BY `last_post_date` DESC LIMIT $limit";
$lastThreads = XenForo_Application::get('db')->fetchAll($sql_forum);
// Here you can insert the code you want
// Displaying content
foreach ($lastThreads as $thread) {
// Constructing full path to threads
$threadUrl = $threadUrl = $forumUrl. XenForo_Link::buildPublicLink('threads', $thread);
// Trimming and escaping
$threadTitle = XenForo_Template_Helper_Core::helperWordTrim($thread['title'], 50);
//Displaying
echo "<a href=\"$threadUrl\">$threadTitle</a> Просмотров: {$thread['view_count']}, Ответов: {$thread['reply_count']}<br /><br />";
}