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}">
			{$attachment_count}
			<div>
			  <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>
			</div>
		</td>
		<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>
		{$rating}
		<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>
		</td>
	{$modbit}
	</tr>
</table>
<br class="clear" />
Edited 11 Aug, 2021, 4:49 pm by Omar G..
Files

You do not have permission to download files.

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

« see more

New thread Omar G. 3 Apr, 2025, 6:26 am

Plugin Releases Plugin Contract Thread

New thread Omar G. 3 Apr, 2025, 6:02 am

Plugin Releases Plugin Extra Forum Permissions

New reply Omar G. 3 Apr, 2025, 4:34 am

Plugin Releases Plugin Forum Cleaner

New reply Omar G. 3 Apr, 2025, 3:59 am

Plugin Releases Plugin Lock Content

New thread Omar G. 3 Apr, 2025, 3:57 am

Plugin Releases Plugin Forum Cleaner

New thread Omar G. 3 Apr, 2025, 3:35 am

Plugin Releases Plugin Lock Content

New thread Omar G. 3 Apr, 2025, 2:16 am

Plugin Releases Paid Plugin Moderator Quick Buttons

New thread Omar G. 29 Mar, 2025, 1:44 am

Plugin Releases Paid Plugin Awards Rules

New thread Omar G. 27 Mar, 2025, 5:53 pm

Plugin Releases Plugin My2FA

New reply Omar G. 23 Mar, 2025, 10:57 am

Plugin Releases Plugin Awards



Current time: 17 Apr, 2025 10:34 am