Search the Community
Showing results for tags 'threads'.
-
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!
-
*** Notice: This topic has a section for self hosted/piggy-back hosted MyBB forums that can access their core files through an FTP account for further capabilities of this function. Unfortunately the further capabilities consist of pulling thread prefixes/styled usernames to show as well and if you use Icyboards you cannot access core files to make these edits BUT you can still use Section One! [1.8] Recent/Latest Post Without A Plugin If you are anything like me you hate a long list of plugins in your ACP and you really hate uploading plugins because anything could go wrong (like accidentally placing files where they don't belong and finding them 3 weeks later thinking "how the ****?". So here is my replacement for this issue. There are two topics for this section. The first is the basic generic "pulling" and the second is a more advanced clean up for self hosted mybb forums (because unfortunately using the built in portals latest posts/threads function does not show thread prefixes (which a lot of people use for dictating whether or not a thread is Mature, Open, Private, etc.) and it also does not style a username with the color/styles attached to the usergroup) which we will fix in that section of this tutorial. Tutorial Created By: Isoldehn Tutorial Permissions: Please do not re-post this tutorial else where, instead link someone to this thread. Tutorial Needs: Overall, the ability to copy and paste. Section 1 - Knowledge Of MyBB Templates Section 2 - FTP Access & Knowledge On Editing Core Files Section One Using the script to pull the threads from the Portal! Please be sure your portal page is enabled and latest posts is enabled/settings configured. I'll let you figure this out on your own because you basically decide how many to show and from what forums/all forums. Step 1: - Open the ACP - Navigate to Templates & Styles --> Templates --> *current template set you are using* --> Portal Templates --> portal - Find: {$latestthreads} - Replace with: <div class="recent_posts">{$latestthreads}</div> Step 2: - Open up the template where ever you would like to add latest threads/posts to. Generally the option is on the index page, or a header, or even a sidebar. I cannot tell you where to place this since this is your choice. - Insert this: <script type="text/javascript"> jQuery(function(){ jQuery(".recent_posts").load("{$mybb->settings['bburl']}/portal.php .recent_posts"); }); </script> <div class="recent_posts"></div> * Credit for this coding is unnecessary as it is a simple script that can be developed by anyone. Step 3: (optional) - Style your latest posts/threads how you like. - Navigate back to Templates & Styles --> Templates --> *current template set you are using* --> Portal Templates --> portal_latestthreads - Create how you would like the div/table to be shown. You can delete everything inside, coding it to your own liking and then add the variable for the threads back in where you would like the thread/post list to show. Variable below for those that accidentally forget to save it. {$threadlist} - Navigate back to Templates & Styles --> Templates --> *current template set you are using* --> Portal Templates --> portal_latestthreads_thread - Again, create this how you would like it to be shown. Variables for things are below in case you forget to save. <a href="{$mybb->settings['bburl']}/{$thread['threadlink']}" title="{$thread['fullsubject']}">{$thread['subject']}</a> (Link to thread and name of thread) <a href="{$thread['forumlink']}">{$thread['forumname']}</a> (Link & name to the forum/board post was created in) <a href="{$thread['lastpostlink']}">Last Post</a> (Link to last post) {$lastposterlink} (Link to the last person that posted) {$lastpostdate} (Date the last post was made) {$thread['replies']} (Number of replies) {$thread['views']} (Number of views) Section Two Fixing the fact that thread prefixes do not show and usergroup styles do not work. Remember, if you continue on with section two we will be editing core files. BEFORE EVER EDITING CORE FILES YOU SHOULD ALWAYS CREATE A BACKUP OF YOUR SITE/FTP AREA (ALL FILES). Just in case anything goes wrong. This tutorial was also created for the MyBB 1.8 Series. If you use this on 1.6 things could very well go horribly wrong and support for 1.6 is no longer offered through MyBB Support. Step 1: - Open your FTP client or your file area where all core files of MyBB can be found. - Navigate to portal.php and open to edit. Step 2: - Find: $latestthreads = ''; // Latest forum discussions - This is the section/area we will be editing. Below those lines (336 & 337) will be all the edits that are being made. Step 3: - Find: $query = $db->query(" SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username - Replace with: $query = $db->query(" SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, t.prefix, u.username, u.usergroup, u.displaygroup Step 4: - Find: LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid) - Replace with: LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.lastposteruid) Step 5: - Find: $lastposterlink = build_profile_link($lastposter, $thread['lastposteruid']); - Replace with: $lastposterlink = build_profile_link(format_name($thread['lastposter'], $thread['usergroup'], $thread['displaygroup']), $thread['lastposteruid']); Step 6: - Find: $thread['subject'] = htmlspecialchars_uni($thread['subject']); $thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']); $thread['threadlink'] = get_thread_link($thread['tid']); $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost"); $thread['forumlink'] = get_forum_link($thread['fid']); $thread['forumname'] = $forum_cache[$thread['fid']]['name']; - Replace with: $prefix = build_prefixes($thread['prefix']); $prefix = $prefix['displaystyle']; $thread['subject'] = $prefix . " " . htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); $thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']); $thread['threadlink'] = get_thread_link($thread['tid']); $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost"); $thread['forumlink'] = get_forum_link($thread['fid']); $thread['forumname'] = $forum_cache[$thread['fid']]['name']; We are now finished!