MyBB Community Forums

Full Version: Today's Posts on homepage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want to add 20 of the most recent posts on the index page. I've used a plugin called "Recent Topics Index Page", but that doesn't format the recent post the way I want it.

When I click on "Today's Post" it is the perfect layout I want:

[attachment=26021]

How do I get the above styled recent post on my homepage?

Please see my current homepage http://syndicate8.co.uk/forum

[attachment=26022]

Is this a big task or is there a quick fix like some code I can add to the index page?

Many thanks.
You need to redo the HTML in that block. Try looking at how the search templates for search results thread are set up and use those as a base.
Thanks for the reply. Since this is a search query, would that imply that it will use a lot of resources? Is it possible to just pull the threads out from the selected forums, just as the plugin is doing?
Hmm, I think I was not clear. What you do, you use the HTML from the template and use that to put the variables in.

It looks like you are using the code from the portal, I did something similar on leefish. assuming that you have TWO templates - latest threads and latest threads threads you could do something like this:

latest threads
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;">
	<tr>
		<td class="thead" colspan="2">
			<div>
				<strong>Recent Posts</strong>
			</div>


		</td>
	</tr>		
	<tr>
	<td class="tcat"><strong>Subject/Author</strong></td>
	<td class="tcat" align="right" width="25%">
              <span class="smalltext"><strong>Last Posted</strong></span></td>
	</tr>
	{$threadlist}
</table>

Latest Threads Threads:
<tr>
<td class="{$altbg}">
              <strong><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong><br />
&raquo;<em>Thread started by</em> {$threadstarter}<br />
</td>
<td class="{$altbg}" align="right" width="20%"><span><br />
&raquo;<em><a href="{$thread['lastpostlink']}">{$lang->latest_threads_lastpost}</a></em> {$lastposterlink}</span><br />
&raquo;{$lastpostdate} {$lastposttime}<br />
</td>
</tr>
Thanks again. I'm very new to php and databases, and can just about understand how it works. I've followed your instructions and edited recenttopics so it displays things correctly under headings. However, it is not the full outcome I wanted. I need it to look exactly as it does in "View Todays Posts" (the image I attached) and I've found the html/php code. However, I do not know where I can pull the information from the database to integrate with this code.

Would you know how I can get this data?

The code I've found is below:

<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
			<tr>
				<td colspan="8" class="thead">
					<strong>{$lang->search_results}</strong>
				</td>
			</tr>
			<tr>
				<td class="tcat" align="center" colspan="3" width="56%"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=subject&amp;order=asc">{$lang->thread}</a> {$orderarrow['subject']}</strong> / <strong><a href="{$sorturl}&amp;sortby=starter&amp;order=asc">{$lang->author}</a> {$orderarrow['starter']}</strong></span></td>
				<td class="tcat" align="center" width="14%"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=forum&amp;order=asc">{$lang->forum}</a> {$orderarrow['forum']}</strong></span></td>
				<td class="tcat" align="center"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=replies&amp;order=desc">{$lang->replies}</a> {$orderarrow['replies']}</strong></span></td>
				<td class="tcat" align="center"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=views&amp;order=desc">{$lang->views}</a> {$orderarrow['views']}</strong></span></td>
				<td class="tcat" align="center" width="200"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=lastpost&amp;order=desc">{$lang->lastpost}</a> {$orderarrow['lastpost']}</strong></span></td>
				{$inlinemodcol}
			</tr>
			{$selectall}
			{$results}
		</table>
You want to be able to sort it? That is a bit hard to do, and I am not really sure you can reuse those headers like that.

The other thing is, that kind of sorting will do a full page reload as well. So if you did manage to plug it all in then you would have to fix the sorting urls.

There is a neat tutorial over on Tomm's site that explains how to do that on a total new page, but you just want it for a single table.

The other option is to go for a javascript solution - tablesorter and jquery. But you would be adding the jquery library and a plugin on page load. It can be done though (I use it on other pages on my board quite successfully).

Here is the link to the plugin - you can have a go at it yourself, or I can implement it for you for a small charge. (pay for my time mostly Big Grin )

http://tablesorter.com/docs/