Tutorial  Use a custom display for the newest thread in the forum display thread list

It is possible you want to display the newest thread in the forum thread list in a special way than the rest, probably separated. You will need a plugin to accomplish this.

Attached is a Hooks file, once you import the attached file to the Hooks plugin system you will be able to:
  • Use {$newestThread} inside the forumdisplay_threadlist template to display the newest thread
  • Create custom newest_forumdisplay_thread and newest_forumdisplay_thread_deleted templates to format the newest thread differently.

Please, note that there are some considerations for this feature:
  • Only one thread will be affected, the newest thread in the forum for the current user, based on pagination, permissions, or filtering features.
  • You can try to use {$newestThread} inside other templates, like in the forumdisplay template, but this was not tested thoroughly.
  • If the newest_forumdisplay_thread and newest_forumdisplay_thread_deleted templates are not found in the theme, the code will simply fallback to the core forumdisplay_thread and forumdisplay_thread_deleted templates.

You can check the attached images for a final result. The newest_forumdisplay_thread template for the attached previews is the following (based off the default theme):
<br class="clear" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder clear">
	<tr class="inline_row">
		<td align="center" class="{$bgcolor}{$thread_type_class}" width="2%"><span class="thread_status {$folder}" title="{$folder_label}">&nbsp;</span></td>
		<td align="center" class="{$bgcolor}{$thread_type_class}" width="2%">{$icon}</td>
		<td class="{$bgcolor}{$thread_type_class}">
			  <span>{$prefix} {$gotounread}{$thread['threadprefix']}<span class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}"><a href="{$thread['threadlink']}">{$thread['subject']}</a></span>{$thread['multipage']}</span>
				<div><span class="author smalltext">{$thread['profilelink']}{$lang->comma}</span><span class="thread_start_datetime smalltext">{$thread['start_datetime']}</span></div>
		<td align="center" class="{$bgcolor}{$thread_type_class}"><a href="{$mybb->settings['bburl']}/misc.php?action=whoposted&tid={$thread['tid']}" onclick="MyBB.whoPosted({$thread['tid']}); return false;">{$thread['replies']}</a>{$unapproved_posts}</td>
		<td align="center" class="{$bgcolor}{$thread_type_class}">{$thread['views']}</td>
		<td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap; text-align: right;">
			<span class="lastpost smalltext">{$lastpostdate}<br />
			<a href="{$thread['lastpostlink']}">{$lang->lastpost}</a>: {$lastposterlink}</span>
<br class="clear" />
This post was last modified: 11 Aug, 2021, 4:49 pm by Omar G..

newest01.jpg (Size: 27.42 KB / Downloads: 602)
There are currently no posts to display. Be the first one to leave a reply.

Current time: 25 May, 2024, 2:31 pm