MyBB Community Forums

Full Version: 30 Most Recent Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
I don't know - I think it would have to be a core file edit. Sad
Is that very complicated? What edits did you do to the newposts.php to make it work, perhaps I can try and work it out myself?
Lets try this for the icon

<?php
 /**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://www.leefish.nl
 * License: Do not sell this 
 *
 * $Id: newposts.php 5297 2012-02-26 22:01:14Z Fish $
 */

 define("IN_MYBB", 1);
 //define("IN_newposts", 1);
 define('THIS_SCRIPT', 'newposts.php');
 // end editing

 $change_dir = "./";

 if(!@chdir($forumdir) && !empty($forumdir))
 {
     if(@is_dir($forumdir))
     {
         $change_dir = $forumdir;
     }
     else
     {
         die("\$forumdir is invalid!");
     }
 }

 $templatelist = "newposts,newposts_latestthreads_thread_lastpost,newposts_latestthreads_thread,ne?wposts_latestthreads,multipage_prevpage,multipage_nextpage,multipage_page_curren?t,multipage_page,multipage_start,multipage_end";

 require_once $change_dir."/global.php";
 require_once MYBB_ROOT."inc/functions_post.php";
 require_once MYBB_ROOT."inc/functions_user.php";
 require_once MYBB_ROOT."inc/class_parser.php";
 $parser = new postParser;

 // Load global language phrases
 $lang->load("portal");

 // Fetch the current URL
 $newposts_url = get_current_location();

 add_breadcrumb("Recent Posts", $mybb->settings['bburl']."/newposts.php");
     
 //pagination settings
 $mybb->settings['newposts_showdiscussions'] = '1';
 $mybb->settings['newposts_showpostsperpage'] = '10';
 $newposts = 110 ;
 $plugins->run_hooks("newposts_start");

 // get forums user cannot view
 $unviewable = get_unviewable_forums(true);
 if($unviewable)
 {
     $unviewwhere = " AND fid NOT IN ($unviewable)";
 }

 // Latest forum discussions
 if($mybb->settings['newposts_showdiscussions'] == 1 && $mybb->settings['newposts_showpostsperpage'])

 $page = intval($mybb->input['page']);
 if($page < 1) $page = 1;
 $perpage = intval($mybb->settings['newposts_showpostsperpage']);
 $multipage = multipage($newposts, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1'.$brl);
 {
     $altbg = alt_trow();
     $threadlist = '';
     $uv = str_replace('fid', 't.fid', $unviewwhere);
	 $icon_cache = $cache->read("posticons");

     $query = $db->query("
     SELECT t.*, u.username, u.displaygroup, u.usergroup, f.name AS forumname
         FROM ".TABLE_PREFIX."threads t
         LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
         LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
         WHERE 1=1 $uv AND t.visible='1'
         ORDER BY t.lastpost DESC 
         LIMIT ".(($page-1)*$perpage).", ".$perpage
     );
     while($thread = $db->fetch_array($query))
     {
         $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
         $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
         
         // Don't link to guest's profiles (they have no profile).
         
         if($thread['lastposteruid'] == 0)
         {
             $lastposterlink = $thread['lastposter'];
         }
         else
         {
         // Build the lastposter username
            
             $lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
         }
		 // Fetch the thread icon if we have one
		if($thread['icon'] > 0 && $icon_cache[$thread['icon']])
		{
			$icon = $icon_cache[$thread['icon']];
			$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
		}
		else
		{
			$icon = "&nbsp;";
		}

         if(my_strlen($thread['subject']) > 45)
         {
             $thread['subject'] = my_substr($thread['subject'], 0, 45) . "...";
         }
         // Build the author username
         $thread['username'] = format_name($thread['username'], $thread['usergroup'], $thread['displaygroup']);
         $threadstarter = build_profile_link($thread['username'], $thread['uid']);
         $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
         $thread['threadlink'] = get_thread_link($thread['tid']);
         $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
         $thread['forumname'] = preg_replace("#&([^\#])(?![a-z1-4]{1,10};)#i", "&$1", $thread['forumname']);
         eval("\$threadlist .= \"".$templates->get("newposts_latestthreads_thread")."\";");
         $altbg = alt_trow();
     }
     if($threadlist)
     { 
         // Show the table only if there are threads
         eval("\$latestthreads = \"".$templates->get("newposts_latestthreads")."\";");
     }
 }

 $plugins->run_hooks("newposts_end");

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

 ?>


and this is the line that made your format work:

$thread['forumname'] = preg_replace("#&([^\#])(?![a-z1-4]{1,10};)#i", "&$1", $thread['forumname']);
That has worked for the post icon, not for the icons in the first column Smile.

Where would I add that code?
The thread icons. Yea, I did tell you it would not get those - do you really want them? This is meant to be a new posts page not a replacement forumdisplay. Toungue

Add what code? The modcp? Look in the modcp.php where the forumname is being called.
Oh ok, I would like them yes as it shows if the threads are hot and if they contain 'threads by you' and such but if it's impossible or close to impossible then I suppose they're not too important.

As for adding that code to the modcp.php, to be honest I have no idea what I'm doing Big Grin, no idea where I should put that code.
I had a look in the mod cp - I cannot really find it either....

If I was in your shoes I would be using css to do this rather than doing it in the ACP the way you have, where do you have this coloured line name showing?

Navigation - index - this new posts - what about search? How does it look there?
The coloured names are showing on the index page and the forum pages and nav, in the search page the code doesn't show but neither does the formatting either, that works for me.

I suppose I'll make another support thread if you're unable to help me with that.

So will it be too difficult to get the icons in the first column or are you going to give it a go? Smile

I have another request although I'm not sure if it's possible, is there a way where clicking on the forum on the new posts page it takes you to the newest post?
lol - also forum display Big Grin

Right now - sorry to be mean - but this is as far as I am willing to go on this page. I have some other projects I am working on you see.
That's absolutely fine, I'm very grateful for your help so far. I'll leave this as unsolved for now and hopefully someone else may be able to help me with that Smile.

Thanks very much.
Pages: 1 2 3 4 5