Jump to content

[DEFUNCT] Recent/Latest Posts Without A Plugin
   (0 reviews)

c.widow
  • 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.

    Software: MyBB

*** 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!


  • Love 1



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.