Jump to content

Lonely/Open Threads Listing
   (0 reviews)

c.widow
  • Lonely, open or other threads listing! An automatic listing of threads with a specified thread prefix replied to within the last specified amount of days with less than a specified amount of replies.

    Software: MyBB 178,177

Lonely/Open Threads Listing

Tutorial Created By: isoldehn
Tutorial Permissions: Please do not re-post this tutorial else where, instead link someone to this thread.

- Additionally, you are NOT required to credit me if you use these codes on your board BUT I do wish for you to share this with those that ask about it if they ever do (share the knowledge, be kind).
Tutorial Needs: Overall, the ability to copy and paste.
- FTP/File Access To Web Space

 

Step One

Create the lonely threads file. Open your FTP client or file manager/file area of your web space. In your MyBB directory (usually located directly in public_html) create a new file called lonelythreads.php and insert the following code.

<?php
// *********************************************************
// * Listing by isoldehn 2019.                             *
// * Free for for general public usage and change!         *
// * Please do not claim as your own nor charge money to   *
// *  install this for others.                             *
// * If any issues contact isoldehn on RPG Initiative.     *
// *********************************************************

define("IN_MYBB", 1);
define('THIS_SCRIPT', 'lonelythreads.php');
$templatelist = "lonelythreads,lonelythreads_entry,lonelythreads_empty";
require "./global.php";
add_breadcrumb("Lonely Threads", "lonelythreads.php");

// *********************************************************
// *********************************************************
// *********************************************************

$query = $db->query("
	SELECT *
	FROM ".TABLE_PREFIX."threads
	WHERE ".TABLE_PREFIX."threads.prefix IN (#)
	AND ".TABLE_PREFIX."threads.replies <= #
	AND ".TABLE_PREFIX."threads.lastpost >= ".TIME_NOW." - (# * 86400)
	ORDER BY lastpost DESC
");

// SPECIFIED PREFIX IDS
// WHERE ".TABLE_PREFIX."threads.prefix IN (#)
// Please insert the pids or pid of the prefix(es) in question. These can be found by navigating to Admin CP --> Configuration --> Thread Prefixes. Click the prefix(es) in question, use the number(s) at the end of url(s).

// SPECIFIED NUMBER OF REPLIES
// AND ".TABLE_PREFIX."threads.replies <= #
// Please insert the least amount of replies needed in order to list the thread. If you do not want a specified amount of replies then remove this AND query.

// SPECIFIED LAST REPLY DATE
// AND ".TABLE_PREFIX."threads.lastpost >= ".TIME_NOW." - (# * 86400)
// Please insert the amount of days from the last post that the thread may be shown. 30 for example will show all threads with a post within the last 30 days.

// *********************************************************
// *********************************************************
// *********************************************************

while($thread=$db->fetch_array($query)) {
    $thread['threadlink'] = get_thread_link($thread['tid']);
	$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
	$thread['threadprefix'] = $threadprefix = '';
		if($thread['prefix'] != 0)
		{
			$threadprefix = build_prefixes($thread['prefix']);
			if(!empty($threadprefix))
			{
				$thread['threadprefix'] = $threadprefix['displaystyle'].' ';
			}
		}
	$thread['author'] = $thread['uid'];
		if(!$thread['username'])
		{
			if(!$thread['threadusername'])
			{
				$thread['username'] = $thread['profilelink'] = htmlspecialchars_uni($lang->guest);
			}
			else
			{
				$thread['username'] = $thread['profilelink'] = htmlspecialchars_uni($thread['threadusername']);
			}
		}
		else
		{
			$thread['username'] = htmlspecialchars_uni($thread['username']);
			$thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);
		}
	$lastpostdate = my_date('relative', $thread['lastpost']);
	$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
	$lastposteruid = $thread['lastposteruid'];
		if(!$lastposteruid && !$thread['lastposter'])
		{
			$lastposter = htmlspecialchars_uni($lang->guest);
		}
		else
		{
			$lastposter = htmlspecialchars_uni($thread['lastposter']);
		}
		$lastpostdate = my_date('relative', $thread['lastpost']);

		// Don't link to guest's profiles (they have no profile).
		if($lastposteruid == 0)
		{
			$lastposterlink = $lastposter;
		}
		else
		{
			$lastposterlink = build_profile_link($lastposter, $lastposteruid);
		}
		
	eval("\$lonelythreads .= \"".$templates->get("lonelythreads_entry")."\";");
}

if (!$lonelythreads)
{
    eval("\$lonelythreads .= \"".$templates->get("lonelythreads_empty")."\";");
}

eval("\$lonelythreads = \"".$templates->get("lonelythreads")."\";");
output_page($lonelythreads);
?>

NOTE(S):

  • Be sure you change all traces of # to the correct ids needed.
    • The file contains // notes for you to follow along to. Please find the notes and edit as suggested.

 

Step Two

Create new templates for our listing. Navigate to Admin CP --> Templates & Style --> Templates --> Global Templates --> Add New Template (for each one).

 

Template Name: lonelythreads

<html>
<head>
<title>{$mybb->settings['bbname']} - Lonely Threads</title>
{$headerinclude}
</head>
<body>
{$header}
	
	<table width="100%" cellpadding="5px" cellspacing="0" border="0">
		<tr>
			<td colspan="5" class="thead">Lonely Threads</td>
		</tr>
		{$lonelythreads}
	</table>
	
{$footer}
</body>
</html>

 

Template Name: lonelythreads_entry

<tr>
	<td style="text-align: center; padding: 10px;" class="trow1">
		{$thread['threadprefix']}
	</td>
	<td style="text-align: left;" class="trow1">
		<a href="{$thread['threadlink']}"><strong>{$thread['subject']}</strong></a>
		<br />
		by {$thread['profilelink']}
	</td>
	<td style="text-align: center;" class="trow1">
		<a href="{$thread['tid']}" onclick="MyBB.whoPosted({$thread['tid']}); return false;">{$thread['replies']}</a> replies
	</td>
	<td style="text-align: center;" class="trow1">
		{$thread['views']} views
	</td>
	<td style="text-align: right;" class="trow1">
		{$lastpostdate}
		<br />
		<a href="{$thread['lastpostlink']}">Last Post</a> by {$lastposterlink}
	</td>
</tr>

 

Template Name: lonelythreads_empty

<tr>
	<td colspan="5" style="text-align: center; padding: 10px;" class="trow1">
		Currently no threads to display.
	</td>
</tr>

 

Step Three

Confirm your new page is working by navigating to yoursiteurl/lonelythreads.php and if it is working appropriately you should see a listing of your specifications!


  • Love 2

Related Guides




User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

There are no reviews to display.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Guidelines and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.