MyBB Community Forums

Full Version: Modifying Core: Where is the loop for outputting POSTS?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I'm heavily modifying the output of the subject and posts of MyBB..

For example, i have str_replace routine function for post['message'] variables, but I only need to do this on the FIRST POST/TOPIC POST.. and not anymore w/ the replies...

My code is working fine already but in my hope to optimize the routine, i need not do my custom substr and str_replace loops on posts that arent the FIRST POST on a thread..

Where is the loop part in this process so that i can do a condition like

if(i=0){ // if first post
// do my routine
}


I looked everywhere in the functions_post.php i cant seem to find it...


thanks
Look around line 800 of showthread.php and you'll find the real loop:
		// Get the actual posts from the database here.
		$pfirst = true;
		$posts = '';
		$query = $db->query("
			SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
			LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
			WHERE $pids
			ORDER BY p.dateline
		");
		while($post = $db->fetch_array($query))
		{
			if($pfirst && $thread['visible'] == 0)
			{
				$post['visible'] = 0;
			}
			$posts .= build_postbit($post);
			$post = '';
			$pfirst = false;
		}
		$plugins->run_hooks("showthread_linear");
As you can see it still calls build_postbit.
nice!! thanks very much.. this has improved my mods significantly Smile