XF Code > WP code. I can't stand developing for Wordpress. If you'd like, I can comment that code to explain what each line does.
<?php
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$conditions = array();
$fetchOptions = array('join' => XenForo_Model_Thread::FETCH_FIRSTPOST,
'order' => DESC,
'limit' => 8);
$threads = $threadModel->getThreadsInForum(2, $conditions, $fetchOptions);
foreach ($threads AS $threadId => $thread) {
if ($threadModel->canViewThread($thread,$thread)) {
echo ('<div class=messageList"><div class="entry-meta subHeading categoryStrip"><a href="' . XenForo_Link::buildPublicLink('canonical:threads', $thread) . '">' . XenForo_Helper_String::wholeWordTrim($thread['title'], 48) . '</a> <p>' . XenForo_Helper_String::wholeWordTrim($thread['message'], 440) . '</p> <span style="float:right; margin-right:60px">Viewed: ' . $thread['view_count'] . '</span><br /></div></div>');
}
}
if (!empty($fetchOptions['order']))
{
$orderBySecondary = '';
switch ($fetchOptions['order'])
{
case 'title':
case 'post_date':
case 'view_count':
$orderBy = 'thread.' . $fetchOptions['order'];
break;
case 'reply_count':
case 'first_post_likes':
$orderBy = 'thread.' . $fetchOptions['order'];
$orderBySecondary = ', thread.last_post_date DESC';
break;
case 'last_post_date':
default:
$orderBy = 'thread.last_post_date';
}
if (!isset($fetchOptions['orderDirection']) || $fetchOptions['orderDirection'] == 'desc')
{
$orderBy .= ' DESC';
}
else
{
$orderBy .= ' ASC';
}
$orderBy .= $orderBySecondary;
}
Its FANTASTIC to see 2 members really going over and above board to help another member..
Kinda reminds me of how things used to be on here at the start..
Great help guys you have helped restore a little faith in forums...
Regards..
if (!empty($fetchOptions['order']))
{
....
default:$orderBy = 'thread.last_post_date';
$orderBy .= ' ASC';
Thank you !It is doing something => throwing an error (at least it should )
Could this code be added to the bottom of any PHP file or can it only run within some sort of XF wrapper. If not, is there some way to modify it so that this can be done?
$fetchOptions = array('join' => XenForo_Model_Thread::FETCH_FIRSTPOST,'order' => DESC,'limit' => 8);
($thread['post'],
Forest they way that ExpertPixels is doing things, is using the XF application code, and inserting the query results into it. You couldn't just stick the .php at the bottom of any old .php page and have it magically work.Hi, all...
Could this code be added to the bottom of any PHP file or can it only run within some sort of XF wrapper. If not, is there some way to modify it so that this can be done?
To put it more concretely, I run a MediaWiki wiki. Could I paste code like the above into the bottom of the appropriate PHP file (the skin file is the appropriate one, I believe, but I can figure that out on my own) and have it output the list of threads? In the long term, I'd like a list of threads that include links to a given Wiki page automatically generated at the bottom of every wiki page. This would, of course, require additional code, but hopefully it makes it clearer what I am trying to do.
$formatter = XenForo_BbCode_Formatter_Base::create('Base'); //see my guide for this explaination
$parser = new XenForo_BbCode_Parser($formatter);
$formatter->parse($message);
Note: You should always use the XenForo_BbCode_Formatter_Base::create($class) method so that various support functionality is added (smilies, bbcode cache, etc.) before rendering happens.
We use essential cookies to make this site work, and optional cookies to enhance your experience.